@@ -24,6 +24,7 @@ namespace BuildingCoder
2424 [ Transaction ( TransactionMode . ReadOnly ) ]
2525 class CmdListSharedParams : IExternalCommand
2626 {
27+ #region Obsolete code that was never used
2728 /// <summary>
2829 /// Get GUID for a given shared param name.
2930 /// </summary>
@@ -48,8 +49,7 @@ static Guid SharedParamGuid( Application app, string defGroup, string defName )
4849 return guid ;
4950 }
5051
51-
52- public Result Execute (
52+ public Result ExecuteObsolete (
5353 ExternalCommandData commandData ,
5454 ref string message ,
5555 ElementSet elements )
@@ -135,5 +135,57 @@ DefinitionBindingMapIterator it
135135 }
136136 return Result . Failed ;
137137 }
138+ #endregion // Obsolete code that was never used
139+
140+ public Result Execute (
141+ ExternalCommandData commandData ,
142+ ref string message ,
143+ ElementSet elements )
144+ {
145+ UIApplication app = commandData . Application ;
146+ UIDocument uidoc = app . ActiveUIDocument ;
147+ Document doc = uidoc . Document ;
148+
149+ BindingMap bindings = doc . ParameterBindings ;
150+
151+ int n = bindings . Size ;
152+
153+ Debug . Print ( "{0} shared parementer{1} defined{2}" ,
154+ n , Util . PluralSuffix ( n ) , Util . DotOrColon ( n ) ) ;
155+
156+ if ( 0 < n )
157+ {
158+ DefinitionBindingMapIterator it
159+ = bindings . ForwardIterator ( ) ;
160+
161+ while ( it . MoveNext ( ) )
162+ {
163+ Definition d = it . Key as Definition ;
164+ Binding b = it . Current as Binding ;
165+
166+ Debug . Assert ( b is ElementBinding ,
167+ "all Binding instances are ElementBinding instances" ) ;
168+
169+ Debug . Assert ( b is InstanceBinding
170+ || b is TypeBinding ,
171+ "all bindings are either instance or type" ) ;
172+
173+ // All definitions obtained in this manner
174+ // are InternalDefinition instances, even
175+ // if they are actually associated with
176+ // shared parameters, i.e. external.
177+
178+ Debug . Assert ( d is InternalDefinition ,
179+ "all definitions obtained from BindingMap are internal" ) ;
180+
181+ string sbinding = ( b is InstanceBinding )
182+ ? "instance"
183+ : "type" ;
184+
185+ Debug . Print ( "{0}: {1}" , d . Name , sbinding ) ;
186+ }
187+ }
188+ return Result . Succeeded ;
189+ }
138190 }
139191}
0 commit comments