當前位置: 首頁>>代碼示例>>C#>>正文


C# Xaml.XamlReader類代碼示例

本文整理匯總了C#中System.Xaml.XamlReader的典型用法代碼示例。如果您正苦於以下問題:C# XamlReader類的具體用法?C# XamlReader怎麽用?C# XamlReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XamlReader類屬於System.Xaml命名空間,在下文中一共展示了XamlReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: XamlBackgroundReader

		public XamlBackgroundReader (XamlReader wrappedReader)
		{
			if (wrappedReader == null)
				throw new ArgumentNullException ("wrappedReader");
			r = wrappedReader;
			q = new XamlNodeQueue (r.SchemaContext) { LineInfoProvider = r as IXamlLineInfo };
		}
開發者ID:nagyist,項目名稱:XamlForIphone,代碼行數:7,代碼來源:XamlBackgroundReader.cs

示例2: DynamicActivityXamlReader

        public DynamicActivityXamlReader(bool isBuilder, XamlReader innerReader, XamlSchemaContext schemaContext)
            : base()
        {
            this.isBuilder = isBuilder;
            this.innerReader = innerReader;
            this.schemaContext = schemaContext ?? innerReader.SchemaContext;

            this.xamlTypeXamlType = this.schemaContext.GetXamlType(typeof(XamlType));
            this.typeXamlType = this.schemaContext.GetXamlType(typeof(Type));

            this.baseActivityXamlType = this.schemaContext.GetXamlType(typeof(Activity));
            this.activityPropertyXamlType = this.schemaContext.GetXamlType(typeof(DynamicActivityProperty));
            this.activityPropertyType = this.activityPropertyXamlType.GetMember("Type");
            this.activityPropertyName = this.activityPropertyXamlType.GetMember("Name");
            this.activityPropertyValue = this.activityPropertyXamlType.GetMember("Value");
            this.activityPropertyAttributes = this.activityPropertyXamlType.GetMember("Attributes");

            this.namespaceTable = new NamespaceTable();
            this.frontLoadedDirectives = true;

            // we pump items through this node-list when rewriting
            this.nodeQueue = new XamlNodeQueue(this.schemaContext);
            this.nodeReader = this.nodeQueue.Reader;
            IXamlLineInfo lineInfo = innerReader as IXamlLineInfo;
            if (lineInfo != null && lineInfo.HasLineInfo)
            {
                this.innerReaderLineInfo = lineInfo;
                this.nodeReaderLineInfo = (IXamlLineInfo)nodeQueue.Reader;
                this.hasLineInfo = true;
            }
        }
開發者ID:uQr,項目名稱:referencesource,代碼行數:31,代碼來源:DynamicActivityXamlReader.cs

示例3: LoadAttributeData

        // We get here when we are inside x:ClassAttributes or x:Property.Attributes. We expect the first element to be the Attribute SO.
        internal static AttributeData LoadAttributeData(XamlReader reader, NamespaceTable namespaceTable, string rootNamespace)
        {
            AttributeData attributeData = null;
            reader.Read();
            if (reader.NodeType == XamlNodeType.StartObject)
            {
                attributeData = new AttributeData { Type = reader.Type };

                bool readNext = false;
                while (readNext || reader.Read())
                {
                    namespaceTable.ManageNamespace(reader);
                    readNext = false;
                    if (reader.NodeType == XamlNodeType.StartMember)
                    {
                        if (reader.Member == XamlLanguage.Arguments)
                        {
                            foreach (AttributeParameterData parameterData in ReadParameters(reader.ReadSubtree(), namespaceTable, rootNamespace))
                            {
                                attributeData.Parameters.Add(parameterData);
                            }
                            readNext = true;
                        }
                        else if (!reader.Member.IsDirective)
                        {
                            KeyValuePair<string, AttributeParameterData> propertyInfo = ReadAttributeProperty(reader.ReadSubtree(), namespaceTable, rootNamespace);
                            attributeData.Properties.Add(propertyInfo.Key, propertyInfo.Value);
                            readNext = true;
                        }
                    }
                }
            }
            return attributeData;
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:35,代碼來源:AttributeData.cs

示例4: ManageNamespace

 public void ManageNamespace(XamlReader reader)
 {
     switch (reader.NodeType)
     {
         case XamlNodeType.NamespaceDeclaration:
             tempNamespaceList.Add(reader.Namespace.Prefix,
                 new NamespaceDeclaration(
                 XamlBuildTaskServices.UpdateClrNamespaceUriWithLocalAssembly(reader.Namespace.Namespace, this.localAssemblyName),
                 reader.Namespace.Prefix));
             break;
         case XamlNodeType.StartObject:
         case XamlNodeType.StartMember:
         case XamlNodeType.GetObject:
             if (tempNamespaceList != null)
             {
                 namespaceStack.Push(tempNamespaceList);
                 tempNamespaceList = new Dictionary<string, NamespaceDeclaration>();
             }
             break;
         case XamlNodeType.EndMember:
         case XamlNodeType.EndObject:
             namespaceStack.Pop();
             break;
         default:
             break;
     }
 }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:27,代碼來源:NamespaceTable.cs

示例5: WriteNode

		public void WriteNode (XamlReader reader)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			switch (reader.NodeType) {
			case XamlNodeType.StartObject:
				WriteStartObject (reader.Type);
				break;
			case XamlNodeType.GetObject:
				WriteGetObject ();
				break;
			case XamlNodeType.EndObject:
				WriteEndObject ();
				break;
			case XamlNodeType.StartMember:
				WriteStartMember (reader.Member);
				break;
			case XamlNodeType.EndMember:
				WriteEndMember ();
				break;
			case XamlNodeType.Value:
				WriteValue (reader.Value);
				break;
			case XamlNodeType.NamespaceDeclaration:
				WriteNamespace (reader.Namespace);
				break;
			default:
				throw NotImplemented (); // documented behavior
			}
		}
開發者ID:nagyist,項目名稱:XamlForIphone,代碼行數:31,代碼來源:XamlWriter.cs

示例6: Main

        static void Main(string[] args)
        {
            Xaml.XamlReader reader = new Xaml.XamlReader();
            Page page = (Page)reader.Load("Test.xaml");
            Console.WriteLine(page.Title);
            var stream = File.Open("Test.html", FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
            StreamWriter writer = new StreamWriter(stream);
            page.Render(writer);
            //writer.Flush();
            //writer.Close();
            Console.ReadLine();

            //XmlWriterSettings setting = new XmlWriterSettings();
            //setting.Encoding = new UTF8Encoding(false);
            //XmlWriter xmlWriter = XmlWriter.Create(writer, setting);
            //xmlWriter.WriteStartDocument();
            //xmlWriter.WriteStartElement("html");
            //xmlWriter.WriteStartElement("span");
            //xmlWriter.WriteString("test");
            //xmlWriter.WriteEndElement();
            //xmlWriter.WriteEndElement();
            //xmlWriter.WriteEndDocument();
            //xmlWriter.Flush();
            //xmlWriter.Close();
            //Console.ReadLine();
        }
開發者ID:Kation,項目名稱:WebPresentation,代碼行數:26,代碼來源:Program.cs

示例7: DynamicActivityXamlReader

 public DynamicActivityXamlReader(bool isBuilder, XamlReader innerReader, XamlSchemaContext schemaContext)
 {
     this.isBuilder = isBuilder;
     this.innerReader = innerReader;
     this.schemaContext = schemaContext ?? innerReader.SchemaContext;
     this.xamlTypeXamlType = this.schemaContext.GetXamlType(typeof(XamlType));
     this.typeXamlType = this.schemaContext.GetXamlType(typeof(System.Type));
     this.baseActivityXamlType = this.schemaContext.GetXamlType(typeof(Activity));
     this.activityPropertyXamlType = this.schemaContext.GetXamlType(typeof(DynamicActivityProperty));
     this.activityPropertyType = this.activityPropertyXamlType.GetMember("Type");
     this.activityPropertyName = this.activityPropertyXamlType.GetMember("Name");
     this.activityPropertyValue = this.activityPropertyXamlType.GetMember("Value");
     this.activityPropertyAttributes = this.activityPropertyXamlType.GetMember("Attributes");
     this.namespaceTable = new NamespaceTable();
     this.frontLoadedDirectives = true;
     this.nodeQueue = new XamlNodeQueue(this.schemaContext);
     this.nodeReader = this.nodeQueue.Reader;
     IXamlLineInfo info = innerReader as IXamlLineInfo;
     if ((info != null) && info.HasLineInfo)
     {
         this.innerReaderLineInfo = info;
         this.nodeReaderLineInfo = (IXamlLineInfo) this.nodeQueue.Reader;
         this.hasLineInfo = true;
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:25,代碼來源:DynamicActivityXamlReader.cs

示例8: ManageNamespace

        public void ManageNamespace(XamlReader reader)
        {
            switch (reader.NodeType)
            {
                case XamlNodeType.StartObject:
                case XamlNodeType.GetObject:
                case XamlNodeType.StartMember:
                    this.EnterScope();
                    return;

                case XamlNodeType.EndObject:
                case XamlNodeType.EndMember:
                    this.ExitScope();
                    break;

                case XamlNodeType.Value:
                    break;

                case XamlNodeType.NamespaceDeclaration:
                    this.AddNamespace(reader.Namespace);
                    return;

                default:
                    return;
            }
        }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:26,代碼來源:NamespaceTable.cs

示例9: Load

        public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider)
        {
            IXamlObjectWriterFactory settings = serviceProvider.GetService(typeof(IXamlObjectWriterFactory)) as IXamlObjectWriterFactory;

            System.Windows.Markup.IProvideValueTarget provideValueService = serviceProvider.GetService(typeof(System.Windows.Markup.IProvideValueTarget)) as System.Windows.Markup.IProvideValueTarget;

            Type propertyType = null;

            // IProvideValueTarget.TargetProperty can return DP, Attached Property or MemberInfo for clr property
            // In this case it should always be a regular clr property here.
            PropertyInfo propertyInfo = provideValueService.TargetProperty as PropertyInfo;

            if (propertyInfo != null)
            {
                propertyType = propertyInfo.PropertyType;
            }
            else
            {
                return null;
            }

            object instance = Activator.CreateInstance(
                typeof(FuncFactory<>).MakeGenericType(propertyType.GetGenericArguments()),
                settings,
                xamlReader);

            return Delegate.CreateDelegate(propertyType, instance, instance.GetType().GetMethod("Evaluate"));
        }
開發者ID:tian1ll1,項目名稱:WPF_Examples,代碼行數:28,代碼來源:FuncFactoryDeferringLoader.cs

示例10: ValidateXaml

        public bool ValidateXaml(XamlReader xamlReader, bool failOnFirstError, string assemblyName, out IList<LogData> validationErrors)
        {
            if (xamlReader == null)
            {
                throw FxTrace.Exception.ArgumentNull("xamlReader");
            }
            validationErrors = null;

            // We loop through the provided XAML using a XamlValidatingReader to ensure that:
            //  1. XAML is valid.
            //  2. All types referenced in XAML are validate-able. At this point, any types defined in the local 
            //     assembly should be referenced, so this should be possible.
            XamlValidatingReader reader = new XamlValidatingReader(xamlReader, this.localAssembly, rootNamespace, assemblyName);
            reader.OnValidationError += new EventHandler<ValidationEventArgs>(reader_OnValidationError);
            while (reader.Read())
            {
                if (this.eventArgs != null && failOnFirstError)
                {
                    validationErrors = this.eventArgs;
                    return false;
                }
            }

            validationErrors = this.eventArgs;
            if (validationErrors != null && validationErrors.Count > 0)
            {
                return false;
            }
            return true;
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:30,代碼來源:ClassValidator.cs

示例11: Transform

        // This method is a workaround for TFS bug #788190, since XamlReader.ReadSubtree() should (but doesn't) preserve IXamlLineInfo on the subreader
        public static void Transform(XamlReader reader, XamlWriter writer, IXamlLineInfo readerLineInfo, bool closeWriter)
        {
            IXamlLineInfoConsumer consumer = writer as IXamlLineInfoConsumer;
            SharedFx.Assert(consumer != null && consumer.ShouldProvideLineInfo, "Should only call this function to write into a XamlNodeQueue.Writer, which is always IXamlLineInfoConsumer");
            bool shouldPassLineNumberInfo = false;
            if (readerLineInfo != null)
            {
                shouldPassLineNumberInfo = true;
            }

            while (reader.Read())
            {
                if (shouldPassLineNumberInfo)
                {
                    consumer.SetLineInfo(readerLineInfo.LineNumber, readerLineInfo.LinePosition);
                }

                writer.WriteNode(reader);
            }

            if (closeWriter)
            {
                writer.Close();
            }
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:26,代碼來源:XamlWriterExtensions.cs

示例12: Initialize

 private void Initialize(XamlReader wrappedReader, int bufferSize)
 {
     XamlNodeNextDelegate delegate4;
     this._providerFullEvent = new EventWaitHandle(false, EventResetMode.AutoReset);
     this._dataReceivedEvent = new EventWaitHandle(false, EventResetMode.AutoReset);
     this._incoming = new XamlNode[bufferSize];
     this._outgoing = new XamlNode[bufferSize];
     this._wrappedReader = wrappedReader;
     this._wrappedReaderHasLineInfo = ((IXamlLineInfo) this._wrappedReader).HasLineInfo;
     XamlNodeAddDelegate add = new XamlNodeAddDelegate(this.Add);
     XamlLineInfoAddDelegate addlineInfoDelegate = null;
     if (this._wrappedReaderHasLineInfo)
     {
         addlineInfoDelegate = new XamlLineInfoAddDelegate(this.AddLineInfo);
     }
     this._writer = new WriterDelegate(add, addlineInfoDelegate, this._wrappedReader.SchemaContext);
     if (this._wrappedReaderHasLineInfo)
     {
         delegate4 = new XamlNodeNextDelegate(this.Next_ProcessLineInfo);
     }
     else
     {
         delegate4 = new XamlNodeNextDelegate(this.Next);
     }
     this._internalReader = new ReaderDelegate(this._wrappedReader.SchemaContext, delegate4, this._wrappedReaderHasLineInfo);
     this._currentNode = new XamlNode(XamlNode.InternalNodeType.StartOfStream);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:27,代碼來源:XamlBackgroundReader.cs

示例13: XamlWrappingReader

 internal XamlWrappingReader(XamlReader underlyingReader)
 {
     if (underlyingReader == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("underlyingReader"));
     }
     _underlyingReader = underlyingReader;
 }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:8,代碼來源:XamlWrappingReader.cs

示例14: Load

        public static XamlDomNode Load(XamlReader xxr)
        {
            var ixli = xxr as IXamlLineInfo;

            var dw = new XamlDomWriter(xxr.SchemaContext);
            XamlServices.Transform(xxr, dw);
            return dw.RootNode;
        }
開發者ID:siwuxian,項目名稱:WinObjC,代碼行數:8,代碼來源:XamlDomServices.cs

示例15: CreateReader

 public static XamlReader CreateReader(XamlReader innerReader)
 {
     if (innerReader == null)
     {
         throw FxTrace.Exception.ArgumentNull("innerReader");
     }
     return new DynamicActivityXamlReader(innerReader);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:8,代碼來源:ActivityXamlServices.cs


注:本文中的System.Xaml.XamlReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。