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


C# IDesignerSerializationManager类代码示例

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


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

示例1: CanCacheComponent

 private bool CanCacheComponent(IDesignerSerializationManager manager, object value, PropertyDescriptorCollection props)
 {
     IComponent component = value as IComponent;
     if (component != null)
     {
         if (component.Site != null)
         {
             INestedSite site = component.Site as INestedSite;
             if ((site != null) && !string.IsNullOrEmpty(site.FullName))
             {
                 return false;
             }
         }
         if (props == null)
         {
             props = TypeDescriptor.GetProperties(component);
         }
         foreach (PropertyDescriptor descriptor in props)
         {
             if (typeof(IComponent).IsAssignableFrom(descriptor.PropertyType) && !descriptor.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden))
             {
                 MemberCodeDomSerializer serializer = (MemberCodeDomSerializer) manager.GetSerializer(descriptor.GetType(), typeof(MemberCodeDomSerializer));
                 if ((serializer != null) && serializer.ShouldSerialize(manager, value, descriptor))
                 {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:ComponentCodeDomSerializer.cs

示例2: Serialize

		public override object Serialize(
			IDesignerSerializationManager manager, object value)
		{
			CodeDomSerializer baseSerializer = manager.GetSerializer(
				typeof(FlowChart).BaseType, typeof(CodeDomSerializer)) as CodeDomSerializer;

			object codeObject = baseSerializer.Serialize(manager, value);

			if (codeObject is CodeStatementCollection)
			{
				CodeStatementCollection code =
					codeObject as CodeStatementCollection;
				FlowChart chart = value as FlowChart;

				// Brushes
				SerializeBrush(code, "BackBrush", chart, chart.BackBrush);
				SerializeBrush(code, "BoxBrush", chart, chart.BoxBrush);
				SerializeBrush(code, "TableBrush", chart, chart.TableBrush);
				SerializeBrush(code, "ArrowBrush", chart, chart.ArrowBrush);

				// Pens
				SerializePen(code, "BoxPen", chart, chart.BoxPen);
				SerializePen(code, "TablePen", chart, chart.TablePen);
				SerializePen(code, "ArrowPen", chart, chart.ArrowPen);

				// Text alignment
				SerializeTextFormat(code, "TextFormat", chart, chart.TextFormat);
			}

			return codeObject;
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:31,代码来源:FlowChartSerializer.cs

示例3: 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

示例4: Serialize

        public override object Serialize(IDesignerSerializationManager manager, object value)
        {
            object codeObject = base.Serialize(manager, value);

            if (codeObject is CodeStatementCollection)
            {
                CodeStatementCollection statements = codeObject as CodeStatementCollection;

                CodeExpression target = base.SerializeToExpression(manager, value);

                RowCollection rows = value as RowCollection;

                if (rows != null)
                {
                    foreach (Row item in rows)
                    {
                        object rowCode = SerializeRow(manager, target, item);

                        if (rowCode is CodeStatementCollection)
                        {
                            statements.AddRange(rowCode as CodeStatementCollection);
                        }
                    }
                }

                foreach (CodeObject item in statements)
                {
                    item.UserData["statement-ordering"] = "end";
                }
            }

            return codeObject;
        }
开发者ID:NtreevSoft,项目名称:GridControl,代码行数:33,代码来源:RowCollectionCodeDomSerializer.cs

示例5: Serialize

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

			Enum[] enums = null;
			TypeConverter converter = TypeDescriptor.GetConverter (value);
			if (converter.CanConvertTo (typeof (Enum[])))
				enums = (Enum[]) converter.ConvertTo (value, typeof (Enum[]));
			else
				enums = new Enum[] { (Enum) value };
			CodeExpression left = null;
			CodeExpression right = null;
			foreach (Enum e in enums) {
				right = GetEnumExpression (e);
				if (left == null) // just the first time
					left = right;
				else
					left = new CodeBinaryOperatorExpression (left, CodeBinaryOperatorType.BitwiseOr, right);
			}

			return left;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:25,代码来源:EnumCodeDomSerializer.cs

示例6: 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

示例7: Deserialize

		public override object Deserialize(IDesignerSerializationManager manager, object codeObject)
		{
			if (manager == null)
				throw new ArgumentNullException("manager");
			if (codeObject == null)
				throw new ArgumentNullException("codeObject");
			
			object instance = null;
			
			CodeStatementCollection statements = codeObject as CodeStatementCollection;
			if (statements != null) {
				foreach (CodeStatement statement in statements) {
					
					if (!this.DeserializeProjectResourceStatement(manager, statement)) {
						object result = this.baseSerializer.Deserialize(manager, new CodeStatementCollection(new [] {statement}));
						if (instance == null) {
							instance = result;
						}
					}
					
				}
				return instance;
			}
			
			return this.baseSerializer.Deserialize(manager, codeObject);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:26,代码来源:ProjectResourcesComponentCodeDomSerializer.cs

示例8: Serialize

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

			if (!(value is Control))
				throw new InvalidOperationException ("value is not a Control");

			object serialized = base.Serialize (manager, value);
			CodeStatementCollection statements = serialized as CodeStatementCollection;
			if (statements != null) { // the root control is serialized to CodeExpression
				ICollection childControls = TypeDescriptor.GetProperties (value)["Controls"].GetValue (value) as ICollection;
				if (childControls.Count > 0) {
					CodeExpression componentRef = base.GetExpression (manager, value);

					CodeStatement statement = new CodeExpressionStatement (
						new CodeMethodInvokeExpression (componentRef, "SuspendLayout"));
					statement.UserData["statement-order"] = "begin";
					statements.Add (statement);
					statement = new CodeExpressionStatement (
						new CodeMethodInvokeExpression (componentRef, "ResumeLayout", 
										new CodeExpression[] { 
											new CodePrimitiveExpression (false) }));
					statement.UserData["statement-order"] = "end";
					statements.Add (statement);
					serialized = statements;
				}
			}
			return serialized;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:32,代码来源:ControlCodeDomSerializer.cs

示例9: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     object obj2 = ((CodeDomSerializer) manager.GetSerializer(typeof(ImageList).BaseType, typeof(CodeDomSerializer))).Serialize(manager, value);
     ImageList list = value as ImageList;
     if (list != null)
     {
         StringCollection keys = list.Images.Keys;
         if (!(obj2 is CodeStatementCollection))
         {
             return obj2;
         }
         CodeExpression targetObject = base.GetExpression(manager, value);
         if (targetObject == null)
         {
             return obj2;
         }
         CodeExpression expression2 = new CodePropertyReferenceExpression(targetObject, "Images");
         if (expression2 == null)
         {
             return obj2;
         }
         for (int i = 0; i < keys.Count; i++)
         {
             if ((keys[i] != null) || (keys[i].Length != 0))
             {
                 CodeMethodInvokeExpression expression3 = new CodeMethodInvokeExpression(expression2, "SetKeyName", new CodeExpression[] { new CodePrimitiveExpression(i), new CodePrimitiveExpression(keys[i]) });
                 ((CodeStatementCollection) obj2).Add(expression3);
             }
         }
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:ImageListCodeDomSerializer.cs

示例10: GetSerializer

 public object GetSerializer(IDesignerSerializationManager manager, object currentSerializer, Type objectType, Type serializerType)
 {
     if (objectType == typeof(Stack))
         return this;
     else
         return currentSerializer;
 }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:7,代码来源:StackSerializer.cs

示例11: ApplyCacheEntry

 internal void ApplyCacheEntry(IDesignerSerializationManager manager, ComponentCache.Entry entry)
 {
     SerializationResourceManager resourceManager = this.GetResourceManager(manager);
     if (entry.Metadata != null)
     {
         foreach (ComponentCache.ResourceEntry entry2 in entry.Metadata)
         {
             resourceManager.SetMetadata(manager, entry2.Name, entry2.Value, entry2.ShouldSerializeValue, true);
         }
     }
     if (entry.Resources != null)
     {
         foreach (ComponentCache.ResourceEntry entry3 in entry.Resources)
         {
             manager.Context.Push(entry3.PropertyDescriptor);
             manager.Context.Push(entry3.ExpressionContext);
             try
             {
                 resourceManager.SetValue(manager, entry3.Name, entry3.Value, entry3.ForceInvariant, entry3.ShouldSerializeValue, entry3.EnsureInvariant, true);
             }
             finally
             {
                 manager.Context.Pop();
                 manager.Context.Pop();
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:ResourceCodeDomSerializer.cs

示例12: GetInitializeMethod

        protected override CodeMemberMethod GetInitializeMethod(IDesignerSerializationManager manager, CodeTypeDeclaration typeDecl, object value)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");
            if (typeDecl == null)
                throw new ArgumentNullException("typeDecl");
            if (value == null)
                throw new ArgumentNullException("value");

            CodeMemberMethod method = typeDecl.UserData[_initMethodKey] as CodeMemberMethod;
            if (method == null)
            {
                method = new CodeMemberMethod();
                method.Name = _initMethodName;
                method.Attributes = MemberAttributes.Private;
                typeDecl.UserData[_initMethodKey] = method;

                // Now create a ctor that calls this method.
                CodeConstructor ctor = new CodeConstructor();
                ctor.Attributes = MemberAttributes.Public;
                ctor.Statements.Add(new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), _initMethodName));
                typeDecl.Members.Add(ctor);
            }
            return method;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:ActivityTypeCodeDomSerializer.cs

示例13: FillLinePragmaFromContext

 private void FillLinePragmaFromContext(IDesignerSerializationManager manager)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:7,代码来源:CodeDomSerializerException.cs

示例14: Serialize

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

			object serialized = null;
			bool isComplete = false;
			CodeExpression createExpr = base.SerializeCreationExpression (manager, value, out isComplete);
			if (isComplete) {
				serialized = createExpr;
				base.SetExpression (manager, value, createExpr);
			} else {
				ExpressionContext context = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
				if (context != null && context.PresetValue == value) {
					CodeStatementCollection statements = new CodeStatementCollection ();
					statements.Add (new CodeAssignStatement (context.Expression, createExpr));
					base.SerializeProperties (manager, statements, value, new Attribute[0]);
					base.SerializeEvents (manager, statements, value, new Attribute[0]);
				} else {
					CodeExpression expression = base.GetExpression (manager, value);
					if (expression == null) {
						serialized = expression = createExpr;
						base.SetExpression (manager, value, expression);
					}
				}
			}
			return serialized;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:30,代码来源:CodeDomSerializer.cs

示例15: Serialize

        public override object Serialize(IDesignerSerializationManager manager, object value) {
            var baseSerializer = (CodeDomSerializer)manager
                .GetSerializer(typeof(ResourceManagerSetter).BaseType, typeof(CodeDomSerializer));
            object codeObject = baseSerializer.Serialize(manager, value);

            var statements = codeObject as CodeStatementCollection;
            if (statements != null) {
                CodeExpression leftCodeExpression = new CodeVariableReferenceExpression("resources");
                var classTypeDeclaration = (CodeTypeDeclaration)manager.GetService(typeof(CodeTypeDeclaration));
                CodeExpression typeofExpression = new CodeTypeOfExpression(classTypeDeclaration.Name);
                CodeExpression rightCodeExpression =
                    new CodeObjectCreateExpression(typeof(XafComponentResourceManager),
                                                                  new[] { typeofExpression });
                //CodeExpression rightCodeExpression =
                //    new CodeTypeReferenceExpression(
                //        "new DevExpress.ExpressApp.Win.Templates"),
                //        "XafComponentResourceManager", new[] { typeofExpression });

                statements.Insert(0, new CodeAssignStatement(leftCodeExpression, rightCodeExpression));
            }

            return codeObject;


        }
开发者ID:aries544,项目名称:eXpand,代码行数:25,代码来源:ResourceManagerSetter.cs


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