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


C# IDesignerSerializationManager.GetSerializer方法代码示例

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


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

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

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

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

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

示例5: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     ToolStripMenuItem item = value as ToolStripMenuItem;
     ToolStrip currentParent = item.GetCurrentParent();
     if (((item != null) && !item.IsOnDropDown) && ((currentParent != null) && (currentParent.Site == null)))
     {
         return null;
     }
     CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(typeof(ImageList).BaseType, typeof(CodeDomSerializer));
     return serializer.Serialize(manager, value);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:ToolStripMenuItemCodeDomSerializer.cs

示例6: Deserialize

		public override object Deserialize(
			IDesignerSerializationManager manager, object codeObject)
		{
			// Simply invoke the base class' method

			CodeDomSerializer baseSerializer = manager.GetSerializer(
				typeof(FlowChart).BaseType, typeof(CodeDomSerializer)) as CodeDomSerializer;

			object obj = baseSerializer.Deserialize(manager, codeObject);

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

示例7: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     if ((manager == null) || (value == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "value");
     }
     CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer));
     if (serializer == null)
     {
         return null;
     }
     object obj2 = serializer.Serialize(manager, value);
     InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(value)[typeof(InheritanceAttribute)];
     InheritanceLevel notInherited = InheritanceLevel.NotInherited;
     if (attribute != null)
     {
         notInherited = attribute.InheritanceLevel;
     }
     if (notInherited != InheritanceLevel.InheritedReadOnly)
     {
         IDesignerHost service = (IDesignerHost) manager.GetService(typeof(IDesignerHost));
         if (service != null)
         {
             PropertyDescriptor descriptor = TypeDescriptor.GetProperties(service.RootComponent)["Localizable"];
             if (((descriptor != null) && (descriptor.PropertyType == typeof(bool))) && ((bool) descriptor.GetValue(service.RootComponent)))
             {
                 this.SerializeControlHierarchy(manager, service, value);
             }
         }
         CodeStatementCollection statements = obj2 as CodeStatementCollection;
         if (statements == null)
         {
             return obj2;
         }
         Control parent = (Control) value;
         if (((service != null) && (parent == service.RootComponent)) || this.HasSitedNonReadonlyChildren(parent))
         {
             this.SerializeSuspendLayout(manager, statements, value);
             this.SerializeResumeLayout(manager, statements, value);
             ControlDesigner designer = service.GetDesigner(parent) as ControlDesigner;
             if (this.HasAutoSizedChildren(parent) || ((designer != null) && designer.SerializePerformLayout))
             {
                 this.SerializePerformLayout(manager, statements, value);
             }
         }
         if (this.HasMixedInheritedChildren(parent))
         {
             this.SerializeZOrder(manager, statements, parent);
         }
     }
     return obj2;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:52,代码来源:ControlCodeDomSerializer.cs

示例8: Deserialize

 public override object Deserialize(IDesignerSerializationManager manager, object codeObject)
 {
     if ((manager == null) || (codeObject == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "codeObject");
     }
     CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer));
     if (serializer == null)
     {
         return null;
     }
     return serializer.Deserialize(manager, codeObject);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:ImageListCodeDomSerializer.cs

示例9: Deserialize

 public virtual object Deserialize(IDesignerSerializationManager manager, object codeObject)
 {
     object component = null;
     if ((manager == null) || (codeObject == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "codeObject");
     }
     using (CodeDomSerializerBase.TraceScope("CodeDomSerializer::Deserialize"))
     {
         CodeExpression expression = codeObject as CodeExpression;
         if (expression != null)
         {
             return base.DeserializeExpression(manager, null, expression);
         }
         CodeStatementCollection statements = codeObject as CodeStatementCollection;
         if (statements != null)
         {
             foreach (CodeStatement statement in statements)
             {
                 if (component == null)
                 {
                     component = this.DeserializeStatementToInstance(manager, statement);
                     if (component != null)
                     {
                         foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(component, new Attribute[] { BrowsableAttribute.Yes }))
                         {
                             if ((!descriptor.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden) && descriptor.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content)) && !(manager.GetSerializer(descriptor.PropertyType, typeof(CodeDomSerializer)) is CollectionCodeDomSerializer))
                             {
                                 this.ResetBrowsableProperties(descriptor.GetValue(component));
                             }
                         }
                     }
                 }
                 else
                 {
                     base.DeserializeStatement(manager, statement);
                 }
             }
             return component;
         }
         if (!(codeObject is CodeStatement))
         {
             string str = string.Format(CultureInfo.CurrentCulture, "{0}, {1}, {2}", new object[] { typeof(CodeExpression).Name, typeof(CodeStatement).Name, typeof(CodeStatementCollection).Name });
             throw new ArgumentException(System.Design.SR.GetString("SerializerBadElementTypes", new object[] { codeObject.GetType().Name, str }));
         }
     }
     return component;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:48,代码来源:CodeDomSerializer.cs

示例10: FindInitializeComponentMethod

		CodeMemberMethod FindInitializeComponentMethod(IDesignerHost host, IDesignerSerializationManager serializationManager)
		{
			this.serializationManager = serializationManager;
			object rootComponent = host.RootComponent;
			TypeCodeDomSerializer serializer = serializationManager.GetSerializer(rootComponent.GetType(), typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;
			CodeTypeDeclaration typeDec = serializer.Serialize(serializationManager, rootComponent, host.Container.Components) as CodeTypeDeclaration;
			foreach (CodeTypeMember member in typeDec.Members) {
				CodeMemberMethod method = member as CodeMemberMethod;
				if (method != null) {
					if (method.Name == "InitializeComponent") {
						return method;
					}
				}
			}
			return null;			
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:16,代码来源:RubyCodeDomSerializer.cs

示例11: Deserialize

 public override object Deserialize(IDesignerSerializationManager manager, object codeObject)
 {
     if ((manager == null) || (codeObject == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "codeObject");
     }
     IContainer service = (IContainer) manager.GetService(typeof(IContainer));
     ArrayList list = null;
     if (service != null)
     {
         list = new ArrayList(service.Components.Count);
         foreach (IComponent component in service.Components)
         {
             Control control = component as Control;
             if (control != null)
             {
                 control.SuspendLayout();
                 list.Add(control);
             }
         }
     }
     object obj2 = null;
     try
     {
         CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer));
         if (serializer == null)
         {
             return null;
         }
         obj2 = serializer.Deserialize(manager, codeObject);
     }
     finally
     {
         if (list != null)
         {
             foreach (Control control2 in list)
             {
                 control2.ResumeLayout(false);
             }
         }
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:43,代码来源:ControlCodeDomSerializer.cs

示例12: Serialize

        /// <summary>
        /// Serializes the specified object into a CodeDOM object.
        /// </summary>
        /// <param name="manager">The serialization manager to use during serialization.</param>
        /// <param name="value">The object to serialize.</param>
        /// <returns>
        /// A CodeDOM object representing the object that has been serialized.
        /// </returns>
        public override object Serialize(IDesignerSerializationManager manager, object value)
        {
            CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(ImageListView).BaseType, typeof(CodeDomSerializer));
            object codeObject = baseSerializer.Serialize(manager, value);

            if (codeObject is CodeStatementCollection)
            {
                CodeStatementCollection statements = (CodeStatementCollection)codeObject;
                CodeExpression imageListViewCode = base.SerializeToExpression(manager, value);
                if (imageListViewCode != null && value is ImageListView)
                {
                    int index = 0;
                    foreach (ImageListView.ImageListViewColumnHeader column in ((ImageListView)value).Columns)
                    {
                        if (!(column.Text == column.DefaultText &&
                            column.Width == ImageListView.DefaultColumnWidth &&
                            column.DisplayIndex == index &&
                            ((index < 4) == column.Visible)))
                        {
                            CodeMethodInvokeExpression columnSetCode = new CodeMethodInvokeExpression(imageListViewCode,
                                "SetColumnHeader",
                                new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(ColumnType)), Enum.GetName(typeof(ColumnType), column.Type)),
                                new CodePrimitiveExpression(column.Text),
                                new CodePrimitiveExpression(column.Width),
                                new CodePrimitiveExpression(column.DisplayIndex),
                                new CodePrimitiveExpression(column.Visible)
                                );
                            if (column.Text == column.DefaultText)
                                columnSetCode.Parameters.RemoveAt(1);
                            statements.Add(columnSetCode);
                        }
                        index++;
                    }
                }

                return codeObject;
            }

            return base.Serialize(manager, value);
        }
开发者ID:ishani,项目名称:InSiDe,代码行数:48,代码来源:ImageListViewSerializer.cs

示例13: PerformLoad

		protected override void PerformLoad (IDesignerSerializationManager manager)
		{
			if (manager == null)
				throw new ArgumentNullException ("manager");

			CodeCompileUnit document = this.Parse ();
			if (document == null)
				throw new NotSupportedException ("The language did not provide a code parser for this file");

			string namespaceName = null;
			CodeTypeDeclaration rootDocument = ExtractFirstCodeTypeDecl (document, out namespaceName);
			if (rootDocument == null)
				throw new InvalidOperationException ("Cannot find a declaration in a namespace to load.");

			_rootSerializer = manager.GetSerializer (manager.GetType (rootDocument.Name), 
													 typeof (RootCodeDomSerializer)) as CodeDomSerializer;
			if (_rootSerializer == null)
				throw new InvalidOperationException ("Serialization not supported for this class");
			_rootSerializer.Deserialize (manager, rootDocument);

			base.SetBaseComponentClassName (namespaceName + "." + rootDocument.Name);
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:22,代码来源:CodeDomDesignerLoader.cs

示例14: Serialize

        public override object Serialize(IDesignerSerializationManager manager, object value)
        {
            CodeDomSerializer baseClassSerializer = (CodeDomSerializer)manager.
                GetSerializer(typeof(BindingManager).BaseType, typeof(CodeDomSerializer));

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

            if(codeObject is CodeStatementCollection && value is BindingManager) {
                CodeStatementCollection statements = (CodeStatementCollection)codeObject;
                BindingManager bindingManager = (BindingManager)value;

                foreach(var action in bindingManager.GetValueActions()) {
                    CodeMethodInvokeExpression methodInvoke = GetSetValueExpression(manager, bindingManager, action);
                    statements.Add(methodInvoke);
                }

                foreach(var action in bindingManager.GetBindingActions()) {
                    CodeMethodInvokeExpression methodInvoke = GetSetBindingExpression(manager, bindingManager, action);
                    statements.Add(methodInvoke);
                }
            }
            return codeObject;
        }
开发者ID:VitalyTVA,项目名称:WinMVVM,代码行数:23,代码来源:BindingManagerCodeDomSerializer.cs

示例15: Serialize

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

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

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

                CodeExpression targetObject =
                    base.SerializeToReferenceExpression(manager, value);
                if (targetObject != null)
                {
                    statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(targetObject, "Owner"),
                        new CodeThisReferenceExpression()));
                }
            }
            return codeObject;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:24,代码来源:NugenCCalcSerializer.cs


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