当前位置: 首页>>代码示例>>C#>>正文


C# IDesignerSerializationManager.GetName方法代码示例

本文整理汇总了C#中IDesignerSerializationManager.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerSerializationManager.GetName方法的具体用法?C# IDesignerSerializationManager.GetName怎么用?C# IDesignerSerializationManager.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDesignerSerializationManager的用法示例。


在下文中一共展示了IDesignerSerializationManager.GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Serialize

		public override object Serialize (IDesignerSerializationManager manager, object value)
		{
			if (value == null)
				throw new ArgumentNullException ("value");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			object serialized = null;
			string name = manager.GetName (value);

			ExpressionContext exprContext = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
			if (exprContext != null && exprContext.PresetValue == value) {
				CodeStatementCollection statements = new CodeStatementCollection ();
				bool isComplete = true;

				statements.Add (new CodeCommentStatement (String.Empty));
				statements.Add (new CodeCommentStatement (name));
				statements.Add (new CodeCommentStatement (String.Empty));
				statements.Add (new CodeAssignStatement (GetFieldReference (manager, name), 
														 base.SerializeCreationExpression (manager, value, out isComplete)));
				base.SerializeProperties (manager, statements, value, new Attribute[0]);
				base.SerializeEvents (manager, statements, value);
				serialized = statements;
			} else {
				serialized = base.Serialize (manager, value);
			}

			return serialized;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:29,代码来源:ComponentCodeDomSerializer.cs

示例2: Serialize

		public virtual CodeTypeDeclaration Serialize (IDesignerSerializationManager manager, object root, ICollection members)
		{
			if (root == null)
				throw new ArgumentNullException ("root");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			RootContext rootContext = new RootContext (new CodeThisReferenceExpression (), root);
			StatementContext statementContext = new StatementContext ();
			if (members != null)
				statementContext.StatementCollection.Populate (members);
			statementContext.StatementCollection.Populate (root);
			CodeTypeDeclaration declaration = new CodeTypeDeclaration (manager.GetName (root));

			manager.Context.Push (rootContext);
			manager.Context.Push (statementContext);
			manager.Context.Push (declaration);

			if (members != null) {
				foreach (object member in members)
					base.SerializeToExpression (manager, member);
			}
			base.SerializeToExpression (manager, root);

			manager.Context.Pop ();
			manager.Context.Pop ();
			manager.Context.Pop ();

			return declaration;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:30,代码来源:TypeCodeDomSerializer.cs

示例3: Serialize

		public virtual object Serialize (IDesignerSerializationManager manager, object value)
		{
			if (value == null)
				throw new ArgumentNullException ("value");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			bool isComplete = true;
			CodeStatementCollection statements = new CodeStatementCollection ();
			ExpressionContext context = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
			object serialized = null;

			if (context != null && context.PresetValue == value) {
				string varName = base.GetUniqueName (manager, value);
				CodeVariableDeclarationStatement statement = new CodeVariableDeclarationStatement (value.GetType (), varName); // declare
				statement.InitExpression = base.SerializeCreationExpression (manager, value, out isComplete); // initialize
				base.SetExpression (manager, value, statement.InitExpression);
				statements.Add (statement);
				serialized = statement;
			} else {
				string name = manager.GetName (value);
				if (name == null)
					name = base.GetUniqueName (manager, value);
				serialized = GetFieldReference (manager, name);
			}

			base.SerializeProperties (manager, statements, value, new Attribute[0]);
			base.SerializeEvents (manager, statements, value, new Attribute[0]);

			return serialized;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:31,代码来源:CodeDomSerializer.cs

示例4: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     PropertyDescriptor descriptor = (PropertyDescriptor) manager.Context[typeof(PropertyDescriptor)];
     ExpressionContext context = (ExpressionContext) manager.Context[typeof(ExpressionContext)];
     bool flag = (value != null) ? CodeDomSerializerBase.GetReflectionTypeHelper(manager, value).IsSerializable : true;
     bool flag2 = !flag;
     bool flag3 = (descriptor != null) && descriptor.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content);
     if (!flag2)
     {
         flag2 = ((context != null) && (context.PresetValue != null)) && (context.PresetValue == value);
     }
     if (((this._model == CodeDomLocalizationModel.PropertyReflection) && !flag3) && !flag2)
     {
         CodeStatementCollection statements = (CodeStatementCollection) manager.Context[typeof(CodeStatementCollection)];
         bool flag4 = false;
         ExtenderProvidedPropertyAttribute attribute = null;
         if (descriptor != null)
         {
             attribute = descriptor.Attributes[typeof(ExtenderProvidedPropertyAttribute)] as ExtenderProvidedPropertyAttribute;
             if ((attribute != null) && (attribute.ExtenderProperty != null))
             {
                 flag4 = true;
             }
         }
         if ((!flag4 && (context != null)) && (statements != null))
         {
             string name = manager.GetName(context.Owner);
             CodeExpression expression = base.SerializeToExpression(manager, context.Owner);
             if ((name != null) && (expression != null))
             {
                 RootContext context2 = manager.Context[typeof(RootContext)] as RootContext;
                 if ((context2 != null) && (context2.Value == context.Owner))
                 {
                     name = "$this";
                 }
                 base.SerializeToResourceExpression(manager, value, false);
                 if (this.EmitApplyMethod(manager, context.Owner))
                 {
                     ResourceManager manager2 = manager.Context[typeof(ResourceManager)] as ResourceManager;
                     CodeMethodReferenceExpression expression3 = new CodeMethodReferenceExpression(base.GetExpression(manager, manager2), "ApplyResources");
                     CodeMethodInvokeExpression expression4 = new CodeMethodInvokeExpression {
                         Method = expression3
                     };
                     expression4.Parameters.Add(expression);
                     expression4.Parameters.Add(new CodePrimitiveExpression(name));
                     statements.Add(expression4);
                 }
                 return null;
             }
         }
     }
     if (flag2)
     {
         return this._currentSerializer.Serialize(manager, value);
     }
     return base.SerializeToResourceExpression(manager, value);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:LocalizationCodeDomSerializer.cs

示例5: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     object obj2 = this.GetBaseSerializer(manager).Serialize(manager, value);
     TableLayoutPanel component = value as TableLayoutPanel;
     if (component != null)
     {
         InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(component)[typeof(InheritanceAttribute)];
         if ((attribute == null) || (attribute.InheritanceLevel != InheritanceLevel.InheritedReadOnly))
         {
             IDesignerHost service = (IDesignerHost) manager.GetService(typeof(IDesignerHost));
             if (this.IsLocalizable(service))
             {
                 PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)[LayoutSettingsPropName];
                 object obj3 = (descriptor != null) ? descriptor.GetValue(component) : null;
                 if (obj3 != null)
                 {
                     string resourceName = manager.GetName(component) + "." + LayoutSettingsPropName;
                     base.SerializeResourceInvariant(manager, resourceName, obj3);
                 }
             }
         }
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:TableLayoutPanelCodeDomSerializer.cs

示例6: SerializeControlHierarchy

 private void SerializeControlHierarchy(IDesignerSerializationManager manager, IDesignerHost host, object value)
 {
     Control control = value as Control;
     if (control != null)
     {
         string str;
         IMultitargetHelperService service = host.GetService(typeof(IMultitargetHelperService)) as IMultitargetHelperService;
         if (control == host.RootComponent)
         {
             str = "$this";
             foreach (IComponent component in host.Container.Components)
             {
                 if (!(component is Control) && !TypeDescriptor.GetAttributes(component).Contains(InheritanceAttribute.InheritedReadOnly))
                 {
                     string name = manager.GetName(component);
                     string str3 = (service == null) ? component.GetType().AssemblyQualifiedName : service.GetAssemblyQualifiedName(component.GetType());
                     if (name != null)
                     {
                         base.SerializeResourceInvariant(manager, ">>" + name + ".Name", name);
                         base.SerializeResourceInvariant(manager, ">>" + name + ".Type", str3);
                     }
                 }
             }
         }
         else
         {
             str = manager.GetName(value);
             if (str == null)
             {
                 return;
             }
         }
         base.SerializeResourceInvariant(manager, ">>" + str + ".Name", manager.GetName(value));
         base.SerializeResourceInvariant(manager, ">>" + str + ".Type", (service == null) ? control.GetType().AssemblyQualifiedName : service.GetAssemblyQualifiedName(control.GetType()));
         Control parent = control.Parent;
         if ((parent != null) && (parent.Site != null))
         {
             string str4;
             if (parent == host.RootComponent)
             {
                 str4 = "$this";
             }
             else
             {
                 str4 = manager.GetName(parent);
             }
             if (str4 != null)
             {
                 base.SerializeResourceInvariant(manager, ">>" + str + ".Parent", str4);
             }
             for (int i = 0; i < parent.Controls.Count; i++)
             {
                 if (parent.Controls[i] == control)
                 {
                     base.SerializeResourceInvariant(manager, ">>" + str + ".ZOrder", i.ToString(CultureInfo.InvariantCulture));
                     return;
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:61,代码来源:ControlCodeDomSerializer.cs

示例7: SerializeToReferenceExpression

 protected CodeExpression SerializeToReferenceExpression(IDesignerSerializationManager manager, object value)
 {
     CodeExpression expression = null;
     using (CodeDomSerializerBase.TraceScope("CodeDomSerializer::SerializeToReferenceExpression"))
     {
         expression = base.GetExpression(manager, value);
         if ((expression != null) || !(value is IComponent))
         {
             return expression;
         }
         string name = manager.GetName(value);
         bool flag = false;
         if (name == null)
         {
             IReferenceService service = (IReferenceService) manager.GetService(typeof(IReferenceService));
             if (service != null)
             {
                 name = service.GetName(value);
                 flag = name != null;
             }
         }
         if (name == null)
         {
             return expression;
         }
         RootContext context = (RootContext) manager.Context[typeof(RootContext)];
         if ((context != null) && (context.Value == value))
         {
             return context.Expression;
         }
         if (flag && (name.IndexOf('.') != -1))
         {
             int index = name.IndexOf('.');
             return new CodePropertyReferenceExpression(new CodeFieldReferenceExpression(_thisRef, name.Substring(0, index)), name.Substring(index + 1));
         }
         return new CodeFieldReferenceExpression(_thisRef, name);
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:38,代码来源:CodeDomSerializer.cs

示例8: GetLegacyExpression

 private CodeExpression GetLegacyExpression(IDesignerSerializationManager manager, object value)
 {
     LegacyExpressionTable table = manager.Context[typeof(LegacyExpressionTable)] as LegacyExpressionTable;
     CodeExpression expression = null;
     if (table != null)
     {
         object obj2 = table[value];
         if (obj2 != value)
         {
             return (obj2 as CodeExpression);
         }
         string name = manager.GetName(value);
         bool flag = false;
         if (name == null)
         {
             IReferenceService service = (IReferenceService) manager.GetService(typeof(IReferenceService));
             if (service != null)
             {
                 name = service.GetName(value);
                 flag = name != null;
             }
         }
         if (name != null)
         {
             RootContext context = (RootContext) manager.Context[typeof(RootContext)];
             if (context != null)
             {
                 if (context.Value == value)
                 {
                     expression = context.Expression;
                 }
                 else if (flag && (name.IndexOf('.') != -1))
                 {
                     int index = name.IndexOf('.');
                     expression = new CodePropertyReferenceExpression(new CodeFieldReferenceExpression(context.Expression, name.Substring(0, index)), name.Substring(index + 1));
                 }
                 else
                 {
                     expression = new CodeFieldReferenceExpression(context.Expression, name);
                 }
             }
             else if (flag && (name.IndexOf('.') != -1))
             {
                 int length = name.IndexOf('.');
                 expression = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression(name.Substring(0, length)), name.Substring(length + 1));
             }
             else
             {
                 expression = new CodeVariableReferenceExpression(name);
             }
         }
         table[value] = expression;
     }
     return expression;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:55,代码来源:CodeDomSerializerBase.cs

示例9: Serialize

		public override object Serialize (IDesignerSerializationManager manager, object value)
		{
			if (value == null)
				throw new ArgumentNullException ("value");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			// Check if we are serializing the root component. Happens, because GetSerializer does not 
			// check for a RootCodeDomSerializer so reference-to type of an expression is delivered
			// by the CodeDomSerializer
			RootContext rootContext = manager.Context[typeof (RootContext)] as RootContext;
			if (rootContext != null && rootContext.Value == value)
				return rootContext.Expression;

			if (((IComponent)value).Site == null) {
				Console.WriteLine ("ComponentCodeDomSerializer: Not sited : " + value);
				return null;
			}

			object serialized = null;
			// the trick with the nested components is that GetName will return the full name
			// e.g splitter1.Panel1 and thus the code below will create a reference to that.
			// 
			string name = manager.GetName (value);

			CodeExpression componentRef = null;
			if (rootContext != null)
				componentRef = new CodeFieldReferenceExpression (rootContext.Expression , name);
			else
				componentRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression () , name);

			ExpressionContext exprContext = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
			if (exprContext != null && exprContext.PresetValue == value) {
				bool isComplete = true;
				CodeStatementCollection statements = new CodeStatementCollection ();
				statements.Add (new CodeCommentStatement (String.Empty));
				statements.Add (new CodeCommentStatement (name));
				statements.Add (new CodeCommentStatement (String.Empty));

				// Do not serialize a creation expression for Nested components
				//
				if (! (((IComponent)value).Site is INestedSite))
					statements.Add (new CodeAssignStatement (componentRef, 
															 base.SerializeCreationExpression (manager, value, out isComplete)));

				manager.Context.Push (new ExpressionContext (componentRef, componentRef.GetType (), null, value));
				base.SerializeProperties (manager, statements, value, new Attribute[0]);
				base.SerializeEvents (manager, statements, value);
				manager.Context.Pop ();

				serialized = statements;
			} else {
				serialized = base.GetExpression (manager, value);
				if (serialized == null) {
					base.SetExpression (manager, value, componentRef);
					serialized = componentRef;
				}
			}

			return serialized;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:61,代码来源:ComponentCodeDomSerializer.cs

示例10: SerializeToExpression

 protected CodeExpression SerializeToExpression(IDesignerSerializationManager manager, object value)
 {
     CodeExpression legacyExpression = null;
     using (TraceScope("SerializeToExpression"))
     {
         if (value != null)
         {
             if (this.IsSerialized(manager, value))
             {
                 legacyExpression = this.GetExpression(manager, value);
             }
             else
             {
                 legacyExpression = this.GetLegacyExpression(manager, value);
                 if (legacyExpression != null)
                 {
                     this.SetExpression(manager, value, legacyExpression);
                 }
             }
         }
         if (legacyExpression != null)
         {
             return legacyExpression;
         }
         CodeDomSerializer serializer = this.GetSerializer(manager, value);
         if (serializer != null)
         {
             CodeStatementCollection statements = null;
             if (value != null)
             {
                 this.SetLegacyExpression(manager, value);
                 StatementContext context = manager.Context[typeof(StatementContext)] as StatementContext;
                 if (context != null)
                 {
                     statements = context.StatementCollection[value];
                 }
                 if (statements != null)
                 {
                     manager.Context.Push(statements);
                 }
             }
             object obj2 = null;
             try
             {
                 obj2 = serializer.Serialize(manager, value);
             }
             finally
             {
                 if (statements != null)
                 {
                     manager.Context.Pop();
                 }
             }
             legacyExpression = obj2 as CodeExpression;
             if ((legacyExpression == null) && (value != null))
             {
                 legacyExpression = this.GetExpression(manager, value);
             }
             CodeStatementCollection statements2 = obj2 as CodeStatementCollection;
             if (statements2 == null)
             {
                 CodeStatement statement = obj2 as CodeStatement;
                 if (statement != null)
                 {
                     statements2 = new CodeStatementCollection();
                     statements2.Add(statement);
                 }
             }
             if (statements2 != null)
             {
                 if (statements == null)
                 {
                     statements = manager.Context[typeof(CodeStatementCollection)] as CodeStatementCollection;
                 }
                 if (statements != null)
                 {
                     statements.AddRange(statements2);
                     return legacyExpression;
                 }
                 string name = "(null)";
                 if (value != null)
                 {
                     name = manager.GetName(value);
                     if (name == null)
                     {
                         name = value.GetType().Name;
                     }
                 }
                 manager.ReportError(System.Design.SR.GetString("SerializerLostStatements", new object[] { name }));
             }
             return legacyExpression;
         }
         manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { value.GetType().FullName }));
     }
     return legacyExpression;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:96,代码来源:CodeDomSerializerBase.cs

示例11: Serialize

		public override object Serialize(IDesignerSerializationManager manager, object value) 
		{
			/* Associate the component with the serializer in the same manner as with
				Deserialize */
			CodeDomSerializer baseClassSerializer = (CodeDomSerializer)manager.
				GetSerializer(typeof(RoundGauge).BaseType, typeof(CodeDomSerializer));
 
			object codeObject = baseClassSerializer.Serialize(manager, value);

			CodeStatementCollection newCode = new CodeStatementCollection();
 
			if (codeObject is CodeStatementCollection) 
			{
				CodeMethodInvokeExpression invokeExpr;
				
				CodeStatementCollection statements = (CodeStatementCollection)codeObject;
 
				// The code statement collection is valid, so add our Begin/EndUpdate calls.
				CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();
				CodeFieldReferenceExpression gaugeRef = new CodeFieldReferenceExpression(thisRef, manager.GetName(value));

				// move the comments and the "new" call
				for(int i = 0 ; i < 4 ; i++)
				{
					newCode.Add(statements[0]);
					statements.RemoveAt(0);
				}
				
				// add BeginInvoke
				invokeExpr = new CodeMethodInvokeExpression(gaugeRef, "BeginUpdate");
				newCode.Add(invokeExpr);

				// add the designer-generated code
				newCode.AddRange(statements);

				// add EndUpdate
				invokeExpr = new CodeMethodInvokeExpression(gaugeRef, "EndUpdate");
				newCode.Add(invokeExpr);
			}
			return newCode;
		}
开发者ID:JeffreyZksun,项目名称:gpstranslator,代码行数:41,代码来源:RoundGauge.cs

示例12: Serialize

		public override object Serialize (IDesignerSerializationManager manager, object value)
		{
			if (value == null)
				throw new ArgumentNullException ("value");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			RootContext rootContext = manager.Context[typeof (RootContext)] as RootContext;
			if (rootContext != null && rootContext.Value == value)
				return rootContext.Expression;

			CodeStatementCollection statements = new CodeStatementCollection ();

			if (((IComponent)value).Site == null) {
				ReportError (manager, "Component of type '" + value.GetType().Name + "' not sited");
				return statements;
			}

			// the trick with the nested components is that GetName will return the full name
			// e.g splitter1.Panel1 and thus the code below will create a reference to that.
			// 
			string name = manager.GetName (value);

			CodeExpression componentRef = null;
			if (rootContext != null)
				componentRef = new CodeFieldReferenceExpression (rootContext.Expression , name);
			else
				componentRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression () , name);

			base.SetExpression (manager, value, componentRef);

			ExpressionContext context = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
			// Perform some heuristics here. 
			// 
			// If there is an ExpressionContext of PropertyReference where PresetValue == this
			// partial serialization doesn't make sense, so perform full. E.g in the case of:
			// 
			// PropertyCodeDomSerializer.SerializeContentProperty and splitContainer1.*Panel1* 
			//
			if (context == null || context.PresetValue != value ||
			    (context.PresetValue == value && (context.Expression is CodeFieldReferenceExpression ||
							      context.Expression is CodePropertyReferenceExpression))) {
				bool isComplete = true;
				statements.Add (new CodeCommentStatement (String.Empty));
				statements.Add (new CodeCommentStatement (name));
				statements.Add (new CodeCommentStatement (String.Empty));
	
				// Do not serialize a creation expression for Nested components
				//
				if (! (((IComponent)value).Site is INestedSite)) {
					CodeStatement assignment = new CodeAssignStatement (componentRef, 
									base.SerializeCreationExpression (manager, value, 
													  out isComplete));
					assignment.UserData["statement-order"] = "initializer";
					statements.Add (assignment);
				}
	
				base.SerializeProperties (manager, statements, value, new Attribute[0]);
				base.SerializeEvents (manager, statements, value);
			}

			return statements;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:63,代码来源:ComponentCodeDomSerializer.cs

示例13: Serialize

 public override CodeTypeDeclaration Serialize(IDesignerSerializationManager manager, object root, ICollection members)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (root == null)
     {
         throw new ArgumentNullException("root");
     }
     Activity activity = root as Activity;
     if (activity == null)
     {
         throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(Activity).FullName }), "root");
     }
     CodeTypeDeclaration declaration = base.Serialize(manager, root, members);
     CodeMemberMethod method = declaration.UserData[_initMethodKey] as CodeMemberMethod;
     if ((method != null) && (activity is CompositeActivity))
     {
         CodeStatement[] array = new CodeStatement[method.Statements.Count];
         method.Statements.CopyTo(array, 0);
         method.Statements.Clear();
         CodeAssignStatement statement = new CodeAssignStatement {
             Left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "CanModifyActivities"),
             Right = new CodePrimitiveExpression(true)
         };
         method.Statements.Add(statement);
         foreach (CodeStatement statement2 in array)
         {
             method.Statements.Add(statement2);
         }
         CodeAssignStatement statement3 = new CodeAssignStatement {
             Left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "CanModifyActivities"),
             Right = new CodePrimitiveExpression(false)
         };
         method.Statements.Add(statement3);
     }
     foreach (CodeTypeMember member in declaration.Members)
     {
         CodeMemberField field = member as CodeMemberField;
         if (field != null)
         {
             foreach (object obj2 in members)
             {
                 if (!(obj2 is Activity))
                 {
                     throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(Activity).FullName }), "members");
                 }
                 Activity activity2 = obj2 as Activity;
                 if (((field.Name == manager.GetName(activity2)) && (((int) activity2.GetValue(ActivityMarkupSerializer.StartLineProperty)) != -1)) && (activity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty) != null))
                 {
                     field.LinePragma = new CodeLinePragma((string) activity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int) activity2.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));
                 }
             }
         }
     }
     return declaration;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:58,代码来源:ActivityTypeCodeDomSerializer.cs

示例14: GetUniqueName

		protected string GetUniqueName (IDesignerSerializationManager manager, object instance)
		{
			if (instance == null)
				throw new ArgumentNullException ("instance");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			string name = manager.GetName (instance);
			if (name == null) {
				INameCreationService service = manager.GetService (typeof (INameCreationService)) as INameCreationService;
				name = service.CreateName (null, instance.GetType ());
				if (name == null)
					name = instance.GetType ().Name.ToLower ();
				manager.SetName (instance, name);
			}
			return name;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:17,代码来源:CodeDomSerializerBase.cs

示例15: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     if ((manager == null) || (value == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "value");
     }
     CodeTypeDeclaration declaration = new CodeTypeDeclaration(manager.GetName(value));
     RootContext context = new RootContext(new CodeThisReferenceExpression(), value);
     using (CodeDomSerializerBase.TraceScope("RootCodeDomSerializer::Serialize"))
     {
         declaration.BaseTypes.Add(value.GetType());
         this.containerRequired = false;
         manager.Context.Push(context);
         manager.Context.Push(this);
         manager.Context.Push(declaration);
         if (!(manager is DesignerSerializationManager))
         {
             manager.AddSerializationProvider(new CodeDomSerializationProvider());
         }
         try
         {
             if (value is IComponent)
             {
                 ISite site = ((IComponent) value).Site;
                 if (site == null)
                 {
                     return declaration;
                 }
                 ICollection components = site.Container.Components;
                 StatementContext context2 = new StatementContext();
                 context2.StatementCollection.Populate(components);
                 manager.Context.Push(context2);
                 try
                 {
                     foreach (IComponent component in components)
                     {
                         if ((component != value) && !base.IsSerialized(manager, component))
                         {
                             if (base.GetSerializer(manager, component) != null)
                             {
                                 base.SerializeToExpression(manager, component);
                             }
                             else
                             {
                                 manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { component.GetType().FullName }));
                             }
                         }
                     }
                     manager.Context.Push(value);
                     try
                     {
                         if ((base.GetSerializer(manager, value) != null) && !base.IsSerialized(manager, value))
                         {
                             base.SerializeToExpression(manager, value);
                         }
                         else
                         {
                             manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { value.GetType().FullName }));
                         }
                     }
                     finally
                     {
                         manager.Context.Pop();
                     }
                 }
                 finally
                 {
                     manager.Context.Pop();
                 }
                 CodeMemberMethod method = new CodeMemberMethod {
                     Name = this.InitMethodName,
                     Attributes = MemberAttributes.Private
                 };
                 declaration.Members.Add(method);
                 ArrayList elements = new ArrayList();
                 foreach (object obj2 in components)
                 {
                     if (obj2 != value)
                     {
                         elements.Add(context2.StatementCollection[obj2]);
                     }
                 }
                 if (context2.StatementCollection[value] != null)
                 {
                     elements.Add(context2.StatementCollection[value]);
                 }
                 if (this.ContainerRequired)
                 {
                     this.SerializeContainerDeclaration(manager, method.Statements);
                 }
                 this.SerializeElementsToStatements(elements, method.Statements);
             }
             return declaration;
         }
         finally
         {
             manager.Context.Pop();
             manager.Context.Pop();
             manager.Context.Pop();
         }
//.........这里部分代码省略.........
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:101,代码来源:RootCodeDomSerializer.cs


注:本文中的IDesignerSerializationManager.GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。