@@ -39,6 +39,14 @@ public void Refresh()
3939 xml = File . ReadAllText ( _fileName ) ;
4040 }
4141 _intelliSense = XmlIntelliSense . Parse ( xml ) ;
42+ if ( _intelliSense ? . XmlFunctionInfo ? . FunctionsList != null )
43+ {
44+ // Fix up SourcePath (is this used?)
45+ foreach ( var func in _intelliSense . XmlFunctionInfo . FunctionsList )
46+ {
47+ func . SourcePath = _fileName ;
48+ }
49+ }
4250 }
4351 catch // (Exception ex)
4452 {
@@ -55,50 +63,6 @@ public IEnumerable<FunctionInfo> GetFunctionInfos()
5563 return _intelliSense . XmlFunctionInfo . FunctionsList ;
5664 }
5765
58- #region Serialized Xml structure
59- [ Serializable ]
60- [ XmlType ( AnonymousType = true ) ]
61- [ XmlRoot ( "IntelliSense" , Namespace = XmlIntelliSense . Namespace , IsNullable = false ) ]
62- public class XmlIntelliSense
63- {
64- [ XmlElement ( "FunctionInfo" ) ]
65- public XmlFunctionInfo XmlFunctionInfo ;
66-
67- // returns XmlIntelliSense.Empty on failure
68- public static XmlIntelliSense Parse ( string xmlFunctionInfo )
69- {
70- Initialize ( ) ;
71- try
72- {
73- using ( var stringReader = new StringReader ( xmlFunctionInfo ) )
74- {
75- return ( XmlIntelliSense ) _serializer . Deserialize ( stringReader ) ;
76- }
77- }
78- catch // (Exception ex)
79- {
80- // TODO: Log errors
81- return Empty ;
82- }
83- }
84-
85- public static void Initialize ( )
86- {
87- if ( _serializer == null )
88- _serializer = new XmlSerializer ( typeof ( XmlIntelliSense ) ) ;
89- }
90- static XmlSerializer _serializer ;
91- public static XmlIntelliSense Empty { get ; } = new XmlIntelliSense { XmlFunctionInfo = new XmlFunctionInfo { FunctionsList = new List < FunctionInfo > ( ) } } ;
92- public const string Namespace = "http://schemas.excel-dna.net/intellisense/" ;
93- }
94-
95- public class XmlFunctionInfo
96- {
97- [ XmlElement ( "Function" , typeof ( FunctionInfo ) ) ]
98- public List < FunctionInfo > FunctionsList ;
99- }
100-
101- #endregion
10266
10367 }
10468
@@ -134,11 +98,12 @@ public void RegisterXmlFunctionInfo(string fileName, string xmlIntelliSense = nu
13498 }
13599 }
136100
137- // Safe to call it wasn't registered
101+ // Safe to call even if it wasn't registered
138102 public void UnregisterXmlFunctionInfo ( string fileName )
139103 {
140104 if ( _xmlRegistrationInfos . Remove ( fileName ) )
141105 _isDirty = true ;
106+ // Not Invalidating - we're not really worried about keeping the extra information around a bit longer
142107 }
143108
144109 public void Initialize ( )
@@ -188,4 +153,49 @@ public void Dispose()
188153 }
189154 }
190155
156+ #region Serialized Xml structure
157+ [ Serializable ]
158+ [ XmlType ( AnonymousType = true ) ]
159+ [ XmlRoot ( "IntelliSense" , Namespace = XmlIntelliSense . Namespace , IsNullable = false ) ]
160+ public class XmlIntelliSense
161+ {
162+ [ XmlElement ( "FunctionInfo" ) ]
163+ public XmlFunctionInfo XmlFunctionInfo ;
164+
165+ // returns XmlIntelliSense.Empty on failure
166+ public static XmlIntelliSense Parse ( string xmlFunctionInfo )
167+ {
168+ Initialize ( ) ;
169+ try
170+ {
171+ using ( var stringReader = new StringReader ( xmlFunctionInfo ) )
172+ {
173+ return ( XmlIntelliSense ) _serializer . Deserialize ( stringReader ) ;
174+ }
175+ }
176+ catch // (Exception ex)
177+ {
178+ // TODO: Log errors
179+ return Empty ;
180+ }
181+ }
182+
183+ public static void Initialize ( )
184+ {
185+ if ( _serializer == null )
186+ _serializer = new XmlSerializer ( typeof ( XmlIntelliSense ) ) ;
187+ }
188+ static XmlSerializer _serializer ;
189+ public static XmlIntelliSense Empty { get ; } = new XmlIntelliSense { XmlFunctionInfo = new XmlFunctionInfo { FunctionsList = new List < FunctionInfo > ( ) } } ;
190+ public const string Namespace = "http://schemas.excel-dna.net/intellisense/1.0" ;
191+ }
192+
193+ [ Serializable ]
194+ public class XmlFunctionInfo
195+ {
196+ [ XmlElement ( "Function" , typeof ( FunctionInfo ) ) ]
197+ public List < FunctionInfo > FunctionsList ;
198+ }
199+
200+ #endregion
191201}
0 commit comments