public static XpsName Get([NotNull] string expandedName)
        {
            if (expandedName == null)
            {
                throw new ArgumentNullException(nameof(expandedName));
            }

            XNamespace @namespace;
            string     localName;

            if (expandedName.StartsWith("{",
                                        StringComparison.Ordinal))
            {
                var index = expandedName.LastIndexOf("}",
                                                     StringComparison.Ordinal);
                @namespace = XNamespace.Get(expandedName.Substring(1,
                                                                   index - 1));
                localName = expandedName.Substring(index + 1);
            }
            else
            {
                @namespace = XNamespace.None;
                localName  = expandedName;
            }

            var result = new XpsName(@namespace,
                                     localName);

            return(result);
        }
            /// <inheritdoc/>
            object IObjectReference.GetRealObject(StreamingContext context)
            {
                XpsName result;

                if (this.ExpandedName == null)
                {
                    result = null;
                }
                else
                {
                    result = XpsName.Get(this.ExpandedName);
                }

                return(result);
            }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public IXpsInputBinDefinition Create(XpsName featureName,
                                             XElement option,
                                             XDocument printCapabilities)
        {
            if (featureName == null)
            {
                throw new ArgumentNullException(nameof(featureName));
            }
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option));
            }
            if (printCapabilities == null)
            {
                throw new ArgumentNullException(nameof(printCapabilities));
            }

            var name = printCapabilities.Root.GetXpsName(option.Attribute(XpsServer.NameName)?.Value);

            if (name == null)
            {
                throw new InvalidOperationException();
            }

            var displayName = option.FindElementByNameAttribute(XpsServer.DisplayNameName)
                              ?.Element(XpsServer.ValueName)
                              ?.GetValue() as string;

            var feedType = option.FindElementByNameAttribute(XpsServer.FeedTypeName)
                           ?.Element(XpsServer.ValueName)
                           ?.GetValue() as XpsName;

            bool isAvailable;

            var constrained = printCapabilities.Root.GetXName(option.Attribute(XpsServer.ConstrainedName)?.Value);

            if (constrained == null)
            {
                isAvailable = true;
            }
            else if (constrained.Equals(XpsServer.DeviceSettingsName))
            {
                isAvailable = false;
            }
            else if (constrained.Equals(XpsServer.NoneName))
            {
                isAvailable = true;
            }
            else
            {
                isAvailable = true;
            }

            var result = new XpsInputBinDefinition
            {
                FeatureName = featureName,
                Name        = name,
                DisplayName = displayName,
                FeedType    = feedType,
                IsAvailable = isAvailable
            };

            return(result);
        }