• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDesignerSerializationManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: DeserializeStatementToInstance

 protected object DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
 {
     object obj2 = null;
     CodeVariableDeclarationStatement statement3;
     CodeAssignStatement statement2 = statement as CodeAssignStatement;
     if (statement2 != null)
     {
         CodeFieldReferenceExpression left = statement2.Left as CodeFieldReferenceExpression;
         if (left != null)
         {
             return base.DeserializeExpression(manager, left.FieldName, statement2.Right);
         }
         CodeVariableReferenceExpression expression2 = statement2.Left as CodeVariableReferenceExpression;
         if (expression2 != null)
         {
             return base.DeserializeExpression(manager, expression2.VariableName, statement2.Right);
         }
         base.DeserializeStatement(manager, statement2);
         return obj2;
     }
     if (((statement3 = statement as CodeVariableDeclarationStatement) != null) && (statement3.InitExpression != null))
     {
         return base.DeserializeExpression(manager, statement3.Name, statement3.InitExpression);
     }
     base.DeserializeStatement(manager, statement);
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:CodeDomSerializer.cs


示例17: GetSerializer

		public object GetSerializer (IDesignerSerializationManager manager, object currentSerializer, 
									 Type objectType, Type serializerType) 
		{
			CodeDomSerializerBase serializer = null;

			if (serializerType == typeof(CodeDomSerializer)) { // CodeDomSerializer
				if (objectType == null) // means that value to serialize is null CodePrimitiveExpression (null)
					serializer = _primitiveSerializer;
				else if (typeof(IComponent).IsAssignableFrom (objectType))
					serializer = _componentSerializer;
				else if (objectType.IsEnum || typeof (Enum).IsAssignableFrom (objectType))
					serializer = _enumSerializer;
				else if (objectType.IsPrimitive || objectType == typeof (String))
					serializer = _primitiveSerializer;
				else if (typeof(ICollection).IsAssignableFrom (objectType)) 
					serializer = _collectionSerializer;
				else
					serializer = _othersSerializer;
			} else if (serializerType == typeof(MemberCodeDomSerializer)) { // MemberCodeDomSerializer
				if (typeof (PropertyDescriptor).IsAssignableFrom (objectType))
					serializer = _propertySerializer;
				else if (typeof (EventDescriptor).IsAssignableFrom (objectType))
					serializer = _eventSerializer;
			} else if (serializerType == typeof (RootCodeDomSerializer)) {
				serializer = _rootSerializer;
			}

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


示例18: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     CodeExpression expression;
     CodeTypeDeclaration declaration = manager.Context[typeof(CodeTypeDeclaration)] as CodeTypeDeclaration;
     RootContext context = manager.Context[typeof(RootContext)] as RootContext;
     CodeStatementCollection statements = new CodeStatementCollection();
     if ((declaration != null) && (context != null))
     {
         CodeMemberField field = new CodeMemberField(typeof(IContainer), "components") {
             Attributes = MemberAttributes.Private
         };
         declaration.Members.Add(field);
         expression = new CodeFieldReferenceExpression(context.Expression, "components");
     }
     else
     {
         CodeVariableDeclarationStatement statement = new CodeVariableDeclarationStatement(typeof(IContainer), "components");
         statements.Add(statement);
         expression = new CodeVariableReferenceExpression("components");
     }
     base.SetExpression(manager, value, expression);
     CodeObjectCreateExpression right = new CodeObjectCreateExpression(typeof(Container), new CodeExpression[0]);
     CodeAssignStatement statement2 = new CodeAssignStatement(expression, right);
     statement2.UserData["IContainer"] = "IContainer";
     statements.Add(statement2);
     return statements;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:ContainerCodeDomSerializer.cs


示例19: ComponentCache

 internal ComponentCache(IDesignerSerializationManager manager)
 {
     this.serManager = manager;
     IComponentChangeService service = (IComponentChangeService) manager.GetService(typeof(IComponentChangeService));
     if (service != null)
     {
         service.ComponentChanging += new ComponentChangingEventHandler(this.OnComponentChanging);
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         service.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemove);
         service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemove);
         service.ComponentRename += new ComponentRenameEventHandler(this.OnComponentRename);
     }
     DesignerOptionService service2 = manager.GetService(typeof(DesignerOptionService)) as DesignerOptionService;
     object obj2 = null;
     if (service2 != null)
     {
         PropertyDescriptor descriptor = service2.Options.Properties["UseOptimizedCodeGeneration"];
         if (descriptor != null)
         {
             obj2 = descriptor.GetValue(null);
         }
         if ((obj2 != null) && (obj2 is bool))
         {
             this.enabled = (bool) obj2;
         }
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:27,代码来源:ComponentCache.cs


示例20: Serialize

		public override void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements)
		{
			if (statements == null)
				throw new ArgumentNullException ("statements");
			if (manager == null)
				throw new ArgumentNullException ("manager");
			if (value == null)
				throw new ArgumentNullException ("value");
			if (descriptor == null)
				throw new ArgumentNullException ("descriptor");

			IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
			if (service != null) {
				// In the propertygrid the events are represented by PropertyDescriptors and the value is a string
				// which contains the method name to bind to. The propertydescriptors are managed and created by the 
				// IEventBindingService
				// 
				EventDescriptor ev = (EventDescriptor) descriptor;
				string methodName = (string) service.GetEventProperty (ev).GetValue (value);
				CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression (new CodeTypeReference (ev.EventType), _thisReference, methodName);
				CodeExpression targetObject = base.SerializeToExpression (manager, value);
				CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression (targetObject, ev.Name);
				statements.Add (new CodeAttachEventStatement (eventRef, listener));
			}
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:25,代码来源:EventCodeDomSerializer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDesktopWindow类代码示例发布时间:2022-05-24
下一篇:
C# IDesignerHost类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap