public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            IComparable valueA = parameters.GetParameter<IComparable>("ValueA");
            IComparable valueB = parameters.GetParameter<IComparable>("ValueB");

            return valueA.CompareTo(valueB);
        }
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            SitemapScope SitemapScope;
            if (parameters.TryGetParameter<SitemapScope>("SitemapScope", out SitemapScope) == false)
            {
                SitemapScope = SitemapScope.Current;
            }

            Guid pageId = Guid.Empty;

            switch (SitemapScope)
            {
                case SitemapScope.Current:
                    pageId = PageRenderer.CurrentPageId;
                    break;
                case SitemapScope.Parent:
                case SitemapScope.Level1:
                case SitemapScope.Level2:
                case SitemapScope.Level3:
                case SitemapScope.Level4:
                    IEnumerable<Guid> pageIds = PageStructureInfo.GetAssociatedPageIds(PageRenderer.CurrentPageId, SitemapScope);
                    pageId = pageIds.FirstOrDefault();
                    break;
                default:
                    throw new NotImplementedException("Unhandled SitemapScope type: " + SitemapScope.ToString());
            }

            return pageId;
        }
 public override object Execute(ParameterList parameters, FunctionContextContainer context)
 {
     return new TitleControl {
         PrefixToRemove = parameters.GetParameter<string>("PrefixToRemove"),
         PostfixToRemove = parameters.GetParameter<string>("PostfixToRemove")
     };
 }
        /// <exclude />
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            XElement element = base.BuildBasicWidgetMarkup("InlineXhtmlEditor", "Xhtml", label, help, bindingSourceName);
            element.Add(new XAttribute("ClassConfigurationName", parameters.GetParameter<string>(ClassConfigurationNameParameterName)));

            var pageId = parameters.GetParameter<Guid>(PreviewPageIdParameterName);
            var templateId = parameters.GetParameter<Guid>(PreviewTemplateIdParameterName);
            string placeholderName = parameters.GetParameter<string>(PreviewPlaceholderParameterName);

            if (pageId != Guid.Empty)
            {
                element.Add(new XAttribute("PreviewPageId", pageId));
            }

            if (templateId != Guid.Empty)
            {
                element.Add(new XAttribute("PreviewTemplateId", templateId));
            }

            if (!string.IsNullOrEmpty(placeholderName))
            {
                element.Add(new XAttribute("PreviewPlaceholder", placeholderName));
            }

            return element;
        }
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            var metaTags = new List<XElement>();

            string contentType = parameters.GetParameter<string>("ContentType");
            string designer = parameters.GetParameter<string>("Designer");
            bool showGenerator = parameters.GetParameter<bool>("ShowGenerator");

            if (!string.IsNullOrWhiteSpace(contentType))
            {
                metaTags.Add(new XElement(Namespaces.Xhtml + "meta",
                    new XAttribute("http-equiv", "Content-Type"),
                    new XAttribute("content", contentType)));
            }

            if (!string.IsNullOrWhiteSpace(designer))
            {
                metaTags.Add(new XElement(Namespaces.Xhtml + "meta",
                    new XAttribute("name", "Designer"),
                    new XAttribute("content", designer)));
            }

            if (showGenerator)
            {
                metaTags.Add(new XElement(Namespaces.Xhtml + "meta",
                    new XAttribute("name", "Generator"),
                    new XAttribute("content", "Composite C1 CMS - Free Open Source from http://composite.net/")));
            }

            return metaTags;
        }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            XElement widgetMarkup = base.BuildBasicWidgetMarkup("DataReferenceSelector", "Selected", label, help, bindingSourceName);
            widgetMarkup.Add(new XElement("DataReferenceSelector.DataType", typeof(IMediaFileFolder).AssemblyQualifiedName));

            return widgetMarkup;
        }
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            object valueA = parameters.GetParameter<object>("ValueA");
            object valueB = parameters.GetParameter<object>("ValueB");

            return valueA.Equals(valueB);
        }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            string markup = parameters.GetParameter<string>(MarkupParameterName) ?? "";

            if (string.IsNullOrWhiteSpace(markup))
            {
                return null;
            }

            markup = @"<cms:formdefinition xmlns:cms=""http://www.composite.net/ns/management/bindingforms/1.0"" xmlns=""http://www.composite.net/ns/management/bindingforms/std.ui.controls.lib/1.0"">"
                      + markup
                      + "</cms:formdefinition>";

            XElement xml = XElement.Parse(markup);

            foreach (var attribute in xml.Descendants().SelectMany(node => node.Attributes()))
            {
                attribute.Value = attribute.Value
                                    .Replace("$label",  label)
                                    .Replace("$binding", bindingSourceName)
                                    .Replace("$help", help != null ? help.HelpText : "");
            }

            return xml.Elements().FirstOrDefault();
        }
		public MethodResponse(string content)
		{
			this.Parameters = new ParameterList();
			LoadOptions options = LoadOptions.None;
			XDocument xDocument = XDocument.Parse(content, options);
			XElement root = xDocument.Root;
			XElement xElement = root.Element("fault");
			if (xElement != null)
			{
				Fault fault = Fault.ParseXml(xElement);
				string message = string.Format("XMLRPC FAULT [{0}]: \"{1}\"", fault.FaultCode, fault.FaultString);
				throw new XmlRPCException(message)
				{
					Fault = fault
				};
			}
			XElement element = root.GetElement("params");
			List<XElement> list = element.Elements("param").ToList<XElement>();
			foreach (XElement current in list)
			{
				XElement element2 = current.GetElement("value");
				Value value = Value.ParseXml(element2);
				this.Parameters.Add(value);
			}
		}
        public override ISource Create(Uri uri, string pageData)
        {
            string userHref = uri.Host;
            string username = userHref.Split('.')[0];

            string title = pageData.GetStringBetween("<title>", "</title>").Trim();
            string currentPageStr = pageData.GetStringBetween("<span id=\"pagination_current_page\"", ">", "<");
            string totalPagesStr = pageData.GetStringBetween("<span id=\"pagination_total_pages\"", ">", "<");

            string pagingUrl = pageData.GetStringBetween("<div class=\"view_pages_page\"", " href=\"", "\"");
            string pagingUrlFormat = Regex.Replace(pagingUrl, @"page=\d+", "page={0}");

            ParameterList parameters = new ParameterList();
            parameters.AddValue(VideoChannelSourceCreator.UserParameterName, username);
            parameters.AddValue(VideoChannelSourceCreator.UserHrefParameterName, userHref);
            parameters.AddValue(VideoChannelSourceCreator.TitleParameterName, title);
            parameters.AddValue(CurrentPageParameterName, int.Parse(currentPageStr));
            parameters.AddValue(TotalPagesParameterName, int.Parse(totalPagesStr));
            parameters.AddValue(PagingUrlFormatParameterName, pagingUrlFormat);

            BlipVideoChannelSource channelSource = new BlipVideoChannelSource(uri, this, parameters);

            var downloadSources = ParseDownloadSources(pageData, channelSource);
            foreach (var downloadSource in downloadSources)
                channelSource.Add(downloadSource);

            return channelSource;
        }
Exemple #11
0
		public PlayLandFromHand(ParameterList<IContext> extraParameters):base(extraParameters) {
			Func<IContext,List<string>> identitySelector = (context) => {
				var card = context as Card;
				return new List<string> () { card.Id }; 
			};
			parameters.Add(new Parameter<IContext>("target",identitySelector));
		}
Exemple #12
0
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            IEnumerable<string> strings = parameters.GetParameter<IEnumerable<string>>("Strings");
            string separator = parameters.GetParameter<string>("Separator");

            return string.Join(separator, strings.ToArray());
        }
Exemple #13
0
        public Data(EntityId readerId, EntityId writerId, long seqNum, ParameterList inlineQosParams, SerializedPayload payload)
            : base(SubMessageKind.DATA)
        {
            this.readerId = readerId;
            this.writerId = writerId;
            this.writerSN = new SequenceNumber(seqNum);

            if (inlineQosParams != null && inlineQosParams.Value.Count > 0)
            {
                Header.FlagsValue |= 0x2;
                this.inlineQosParams = inlineQosParams;
            }

            if (payload.ContainsData())
            {
                Header.FlagsValue |= Flags.DataFlag; // dataFlag
            }
            else
            {
                Header.FlagsValue |= Flags.KeyFlag; // keyFlag
            }


            this.serializedPayload = payload;
        }
		public override object Execute(ParameterList parameters, FunctionContextContainer context)
		{
			var result = new XhtmlDocument();
			var functionCall = new XElement(Composite.Core.Xml.Namespaces.Function10 + "function",
				new XAttribute("name", "Composite.Forms.RendererControl"));
			BaseRuntimeTreeNode paramNode = null;

			foreach (var parameterName in parameters.AllParameterNames)
			{
				try
				{

					if (parameters.TryGetParameterRuntimeTreeNode(parameterName, out paramNode))
					{
						functionCall.Add(paramNode.Serialize());
					}
				}
				//Ignore
				catch { }
			}
			result.Body.Add(
				new XElement(Namespaces.AspNetControls + "form",
					functionCall));
			return result;
		}
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            IEnumerable elements = parameters.GetParameter<IEnumerable>("Elements");
            string keyPropertyName = parameters.GetParameter<string>("KeyPropertyName");
            string valuePropertyName = parameters.GetParameter<string>("ValuePropertyName");

            Dictionary<string, string> resultDictionary = new Dictionary<string, string>();

            PropertyInfo keyPropertyInfo = null;
            PropertyInfo valuePropertyInfo = null;
            foreach (object element in elements)
            {
                if (keyPropertyInfo == null)
                {
                    keyPropertyInfo = element.GetType().GetProperty(keyPropertyName);
                }

                if (valuePropertyInfo == null)
                {
                    valuePropertyInfo = element.GetType().GetProperty(valuePropertyName);
                }

                string keyValue = keyPropertyInfo.GetValue(element, null).ToString();
                string valueValue = valuePropertyInfo.GetValue(element, null).ToString();

                resultDictionary.Add(keyValue, valueValue);
            }

            return resultDictionary;
        }
Exemple #16
0
        protected ChannelSource(Uri uri, ChannelSourceCreator creator, ParameterList parameters)
            : base(uri, parameters)
        {
            SetParameterValue(ChannelSourceCreator.CreatorParameterName, creator);

            DownloadSources = new ObservableDownloadSourceCollection();
        }
Exemple #17
0
 internal Statement(IHost host)
     : base(host)
 {
     Attributes = new AttributeList(host);
     Children = new StatementList(host);
     Parameters = new ParameterList(host);
 }
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            string commaSeparatedSearchTerms = parameters.GetParameter<string>("CommaSeparatedGuids");

            if (!commaSeparatedSearchTerms.IsNullOrEmpty())
            {
                ParameterExpression parameter = Expression.Parameter(typeof(Guid), "g");

                IEnumerable<string> guidStrings = commaSeparatedSearchTerms.Split(',');

                Expression body = null;

                foreach (string guidString in guidStrings)
                {
                    Guid temp = new Guid(guidString.Trim());

                    Expression part = Expression.Equal(parameter, Expression.Constant(temp));

                    body = body.NestedOr(part);
                }

                if(body != null)
                {
                    return Expression.Lambda<Func<Guid, bool>>(body, parameter);
                }
            }

            return (Expression<Func<Guid, bool>>) (f => false);
        }
Exemple #19
0
		void Initialize_NoLock() {
			try {
				if (initCounter++ != 0) {
					Debug.Fail("Initialize() called recursively");
					return;
				}

				if (parameterList == null)
					parameterList = new ParameterList(this, ownerType);

				declaringType2 = ownerType;
				InitNameAndAttributes_NoLock();
				InitRVA_NoLock();
				InitCustomAttributes_NoLock();
				InitDeclSecurities_NoLock();
				InitGenericParams_NoLock();
				InitSignature_NoLock();
				Debug.Assert(CanFreeMethodBody, "Can't free method body");
				FreeMethodBody();
				InitParamDefs_NoLock();
				ResetImplMap();
				semAttrs = 0;
				overrides = null;
				this.parameterList.UpdateParameterTypes();
				canFreeMethodBody = !ownerType.CompletelyLoaded;
			}
			finally {
				initCounter--;
			}
		}
        public override ISource Create(Uri uri, string pageData)
        {
            string userHref = pageData.GetStringBetween("<link rel=\"canonical\"", " href=\"", "\"");
            string username = userHref.GetStringBetween("/user/", null);

            string title = pageData.GetStringBetween("<meta name=\"title\" content=\"", "\"");
            string description = pageData.GetStringBetween("<meta name=\"description\" content=\"", "\"");
            string thumbnail = pageData.GetStringBetween("<meta property=\"og:image\" content=\"", "\"");

            // thumbnail format changed (no http/s)
            // //i1.ytimg.com/i/dbL-i29FDPYok8X8yIynNQ/1.jpg?v=9aee31

            string ajaxSessionInfo = pageData.GetStringBetween("window.ajax_session_info", "'", "'");

            var parameters = new ParameterList();
            parameters.AddValue(UserParameterName, username);
            parameters.AddValue(UserHrefParameterName, userHref);
            parameters.AddValue(TitleParameterName, title);
            parameters.AddValue(DescriptionParameterName, description);
            parameters.AddValue(ThumbnailParameterName, thumbnail);
            parameters.AddValue(AjaxSessionInfoParameterName, ajaxSessionInfo);

            var channelSource = new YoutubeVideoChannelSource(uri, this, parameters);

            var downloadSources = ParseDownloadSources(pageData, channelSource);
            foreach (var downloadSource in downloadSources)
                channelSource.Add(downloadSource);

            return channelSource;
        }
		public override object Execute(ParameterList parameters, FunctionContextContainer context)
		{
			var result = new List<FormEmail>();
			result.AddRange(parameters.GetParameter<IEnumerable<FormEmail>>("EmailA"));
			result.AddRange(parameters.GetParameter<IEnumerable<FormEmail>>("EmailB"));
			return result;
		}
 public override object Execute(ParameterList parameters, FunctionContextContainer context)
 {
     return new XsltExtensionDefinition<GlobalizationXsltExtensions>
     {
         EntensionObject = new GlobalizationXsltExtensions(),
         ExtensionNamespace = "#globalizationExtensions"
     };
 }
Exemple #23
0
 public StatementBuilder(DBConnection c, string tableName)
 {
     Database = c;
     Data = new ParameterList(c);
     Parameters = new ParameterList(c);
     TableName = tableName;
     SkipTableHeader = string.Format("{0}.", TableName);
 }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            string spritePath = parameters.GetParameter<string>(SvgIconSelectorWidgetFuntion.SvgSpritePathParameterName);

            XElement formElement = base.BuildBasicWidgetMarkup("SvgIconSelector", "Selected", label, help, bindingSourceName);
            formElement.Add(new XAttribute("SvgSpritePath", spritePath));
            return formElement;
        }
Exemple #25
0
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            string stringA = parameters.GetParameter<string>("StringA");
            string stringB = parameters.GetParameter<string>("StringB");
            string separator = parameters.GetParameter<string>("Separator");

            return stringA + separator + stringB;
        }
 public override object Execute(ParameterList parameters, FunctionContextContainer context)
 {
     return new XsltExtensionDefinition<MarkupParserXsltExtensions>
     {
         EntensionObject = new MarkupParserXsltExtensions(),
         ExtensionNamespace = "#MarkupParserExtensions"
     };
 }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            bool spellCheck = parameters.GetParameter<bool>(TextBoxWidgetFuntion.SpellCheckParameterName);

            XElement formElement = base.BuildBasicWidgetMarkup("TextBox", "Text", label, help, bindingSourceName);
            formElement.Add(new XAttribute("SpellCheck", spellCheck));
            return formElement;
        }
 public override object Execute(ParameterList parameters, FunctionContextContainer context)
 {
     return new XsltExtensionDefinition<DateFormattingXsltExtensions>
     {
         EntensionObject = new DateFormattingXsltExtensions(),
         ExtensionNamespace = "#dateExtensions"
     };
 }
 void Start()
 {
     inspector = GameObject.Find ("Inspector").GetComponent ("Inspector") as Inspector;
     objectList = GameObject.Find ("ObjectList").GetComponent ("ObjectList") as ObjectList;
     parameterList = GameObject.Find ("ParameterList").GetComponent ("ParameterList") as ParameterList;
     startPosition = transform.position;
     startRotation = transform.eulerAngles;
 }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            XElement textBoxMarkup = base.BuildBasicWidgetMarkup("TextBox", "Text", label, help, bindingSourceName);

            textBoxMarkup.Add(new XAttribute("Type", TextBoxType.Decimal));

            return textBoxMarkup;
        }
Exemple #31
0
 public abstract object Execute(ParameterList parameters, FunctionContextContainer context);
Exemple #32
0
 /// <summary>Updates a Broker record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Update(ParameterList parameters)
 {
     // Accessor for the Broker Table.
     ServerMarketData.BrokerDataTable brokerTable = ServerMarketData.Broker;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     object name = parameters["name"].Value;
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     object externalAdvertisementStylesheetId = parameters["advertisementStylesheetId"].Value;
     object externalDestinationOrderDetailStylesheetId = parameters["destinationOrderDetailStylesheetId"].Value;
     object externalDestinationOrderStylesheetId = parameters["destinationOrderStylesheetId"].Value;
     object externalExecutionDetailStylesheetId = parameters["executionDetailStylesheetId"].Value;
     object externalExecutionStylesheetId = parameters["executionStylesheetId"].Value;
     object externalMatchStylesheetId = parameters["matchStylesheetId"].Value;
     object externalMatchHistoryStylesheetId = parameters["matchHistoryStylesheetId"].Value;
     object externalPartyTypeCode = parameters["partyTypeCode"].Value;
     object externalSourceOrderDetailStylesheetId = parameters["sourceOrderDetailStylesheetId"].Value;
     object externalSourceOrderStylesheetId = parameters["sourceOrderStylesheetId"].Value;
     object externalWorkingOrderStylesheetId = parameters["workingOrderStylesheetId"].Value;
     object buyMarketValueThreshold = parameters["buyMarketValueThreshold"].Value;
     object buyQuantityThreshold = parameters["buyQuantityThreshold"].Value;
     object sellMarketValueThreshold = parameters["sellMarketValueThreshold"].Value;
     object sellQuantityThreshold = parameters["sellQuantityThreshold"].Value;
     object shortName = parameters["shortName"].Value;
     string externalBrokerId = ((string)(parameters["brokerId"]));
     object connected = parameters["connected"].Value;
     object phone = parameters["phone"].Value;
     object symbol = parameters["symbol"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     object advertisementStylesheetId = Stylesheet.FindOptionalKey(configurationId, "advertisementStylesheetId", externalAdvertisementStylesheetId);
     object destinationOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderDetailStylesheetId", externalDestinationOrderDetailStylesheetId);
     object destinationOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderStylesheetId", externalDestinationOrderStylesheetId);
     object executionDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionDetailStylesheetId", externalExecutionDetailStylesheetId);
     object executionStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionStylesheetId", externalExecutionStylesheetId);
     object matchStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchStylesheetId", externalMatchStylesheetId);
     object matchHistoryStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchHistoryStylesheetId", externalMatchHistoryStylesheetId);
     object partyTypeCode = PartyType.FindOptionalKey(configurationId, "partyTypeCode", externalPartyTypeCode);
     object sourceOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderDetailStylesheetId", externalSourceOrderDetailStylesheetId);
     object sourceOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderStylesheetId", externalSourceOrderStylesheetId);
     object workingOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "workingOrderStylesheetId", externalWorkingOrderStylesheetId);
     int brokerId = Source.FindRequiredKey(configurationId, "brokerId", externalBrokerId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.BrokerRow brokerRow = brokerTable.FindByBrokerId(brokerId);
     rowVersion = ((long)(brokerRow[brokerTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Broker.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, workingOrderStylesheetId, buyMarketValueThreshold, buyQuantityThreshold, sellMarketValueThreshold, sellQuantityThreshold, shortName, brokerId, connected, phone, symbol, typeCode);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #33
0
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            var codeAttributeDeclaration = new CodeAttributeDeclaration(new CodeTypeReference(typeof(Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidatorAttribute)));

            return(new ConstructorBasedPropertyValidatorBuilder <string>(codeAttributeDeclaration, new Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidatorAttribute()));
        }
Exemple #34
0
 /// <summary>
 /// 序列化
 /// </summary>
 /// <param name="writer">存放序列化后的结果</param>
 public void Serialize(BinaryWriter writer)
 {
     writer.Write(PublicKeyHash);
     writer.WriteVarBytes(ParameterList.Cast <byte>().ToArray());
     writer.WriteVarBytes(Script);
 }
Exemple #35
0
        public override object Execute(ParameterList parameters, FunctionContextContainer context)
        {
            var codeAttributeDeclaration = new CodeAttributeDeclaration(new CodeTypeReference(typeof(StringSizeValidatorAttribute)));

            return(new ConstructorBasedPropertyValidatorBuilder <string>(codeAttributeDeclaration, new PasswordValidatorAttribute()));
        }
Exemple #36
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     return(obj.update(pl, api));
 }
Exemple #37
0
        /// <summary>
        /// Add the parameters section for the provided <paramref name="mathod"/>.
        /// </summary>
        /// <param name="method">The method to add the parameters for.</param>
        /// <param name="parsedBlocks">The parsed comments.</param>
        protected void AddParametersForMethod(MethodDef method, List <Block> parsedBlocks)
        {
            // Add the parameter information if available
            List <Param> parameterComments = Parser.ParseElement <Param>(parsedBlocks);

            if (method.Parameters != null && method.Parameters.Count > 0)
            {
                ParameterList parameters = null;
                foreach (ParamDef methodParam in method.Parameters)
                {
                    if (methodParam.Sequence != 0)
                    {
                        // Find the parameter comments
                        Param paramComment = null;
                        foreach (Param current in parameterComments)
                        {
                            if (current.Name == methodParam.Name)
                            {
                                paramComment = current;
                                break;
                            }
                        }

                        TypeRef  typeRef  = method.ResolveParameter(methodParam.Sequence);
                        EntryKey typeKey  = null;
                        string   typeName = typeRef.Name;
                        if (parameters == null)
                        {
                            parameters = new ParameterList();
                        }
                        if (typeRef != null)
                        {
                            if (typeRef is TypeDef)
                            {
                                typeKey = new EntryKey(typeRef.GetGloballyUniqueId());
                            }
                            else
                            {
                                CRefPath            path  = new CRefPath(typeRef);
                                Documentation.Entry found = LiveDocumentorFile.Singleton.LiveDocument.Find(path);
                                if (found != null)
                                {
                                    typeKey  = new EntryKey(found.Key);
                                    typeName = found.Name;
                                }
                                else
                                {
                                    typeKey = null;
                                }
                            }
                            typeName = typeRef.GetDisplayName(false);
                        }
                        List <Block> paramDescription = new List <Block>();
                        if (paramComment != null && paramComment.Description != null)
                        {
                            paramDescription = paramComment.Description;
                        }
                        parameters.Add(methodParam.Name, typeName, method.Assembly, typeKey, paramDescription);
                    }
                }
                if (parameters != null)
                {
                    this.Blocks.Add(parameters);
                }
            }
        }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition help, string bindingSourceName)
        {
            XElement formElement = base.BuildBasicWidgetMarkup("ConsoleIconSelector", "Selected", label, help, bindingSourceName);

            return(formElement);
        }
Exemple #39
0
        protected override IEnumerable <object> EnumerateReferences(ParameterList record)
        {
            yield return(record.ParameterListAssociations);

            yield return(record.ListIdentifier);
        }
Exemple #40
0
 /// <summary>Loads a Broker record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Load(ParameterList parameters)
 {
     // Accessor for the Broker Table.
     ServerMarketData.BrokerDataTable brokerTable = ServerMarketData.Broker;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     string name = parameters["name"];
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     object externalAdvertisementStylesheetId = parameters["advertisementStylesheetId"].Value;
     object externalDestinationOrderDetailStylesheetId = parameters["destinationOrderDetailStylesheetId"].Value;
     object externalDestinationOrderStylesheetId = parameters["destinationOrderStylesheetId"].Value;
     object externalExecutionDetailStylesheetId = parameters["executionDetailStylesheetId"].Value;
     object externalExecutionStylesheetId = parameters["executionStylesheetId"].Value;
     object externalMatchStylesheetId = parameters["matchStylesheetId"].Value;
     object externalMatchHistoryStylesheetId = parameters["matchHistoryStylesheetId"].Value;
     string externalPartyTypeCode = parameters["partyTypeCode"];
     object externalSourceOrderDetailStylesheetId = parameters["sourceOrderDetailStylesheetId"].Value;
     object externalSourceOrderStylesheetId = parameters["sourceOrderStylesheetId"].Value;
     object externalWorkingOrderStylesheetId = parameters["workingOrderStylesheetId"].Value;
     object buyMarketValueThreshold = parameters["buyMarketValueThreshold"].Value;
     object buyQuantityThreshold = parameters["buyQuantityThreshold"].Value;
     object sellMarketValueThreshold = parameters["sellMarketValueThreshold"].Value;
     object sellQuantityThreshold = parameters["sellQuantityThreshold"].Value;
     string shortName = parameters["shortName"];
     string externalBrokerId = parameters["brokerId"];
     object connected = parameters["connected"].Value;
     object phone = parameters["phone"].Value;
     string symbol = parameters["symbol"];
     object externalTypeCode = parameters["typeCode"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     object advertisementStylesheetId = Stylesheet.FindOptionalKey(configurationId, "advertisementStylesheetId", externalAdvertisementStylesheetId);
     object destinationOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderDetailStylesheetId", externalDestinationOrderDetailStylesheetId);
     object destinationOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderStylesheetId", externalDestinationOrderStylesheetId);
     object executionDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionDetailStylesheetId", externalExecutionDetailStylesheetId);
     object executionStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionStylesheetId", externalExecutionStylesheetId);
     object matchStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchStylesheetId", externalMatchStylesheetId);
     object matchHistoryStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchHistoryStylesheetId", externalMatchHistoryStylesheetId);
     int partyTypeCode = PartyType.FindRequiredKey(configurationId, "partyTypeCode", externalPartyTypeCode);
     object sourceOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderDetailStylesheetId", externalSourceOrderDetailStylesheetId);
     object sourceOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderStylesheetId", externalSourceOrderStylesheetId);
     object workingOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "workingOrderStylesheetId", externalWorkingOrderStylesheetId);
     int brokerId = Source.FindKey(configurationId, "brokerId", externalBrokerId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     ServerMarketData.BrokerRow brokerRow = brokerTable.FindByBrokerId(brokerId);
     // The load operation will create a record if it doesn't exist, or update an existing record.  The external
     // identifier is used to determine if a record exists with the same key.
     if ((brokerRow == null))
     {
         // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
         // external method is called with the same 'configurationId' parameter.
         int externalKeyIndex = Broker.GetExternalKeyIndex(configurationId, "brokerId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalBrokerId;
         object externalId0 = externalIdArray[0];
         object externalId1 = externalIdArray[1];
         object externalId2 = externalIdArray[2];
         object externalId3 = externalIdArray[3];
         object externalId4 = externalIdArray[4];
         object externalId5 = externalIdArray[5];
         object externalId6 = externalIdArray[6];
         object externalId7 = externalIdArray[7];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Broker.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, workingOrderStylesheetId, buyMarketValueThreshold, buyQuantityThreshold, sellMarketValueThreshold, sellQuantityThreshold, shortName, connected, phone, symbol, typeCode);
     }
     else
     {
         // While the optimistic concurrency checking is disabled for the external methods, the internal methods
         // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
         // will bypass the coused when the internal method is called.
         rowVersion = ((long)(brokerRow[brokerTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Broker.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, workingOrderStylesheetId, buyMarketValueThreshold, buyQuantityThreshold, sellMarketValueThreshold, sellQuantityThreshold, shortName, brokerId, connected, phone, symbol, typeCode);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #41
0
 /// <summary> Creates a EntropyCoder object for the appropriate entropy coding
 /// parameters in the parameter list 'pl', and having 'src' as the source
 /// of quantized data.
 ///
 /// </summary>
 /// <param name="src">The source of data to be entropy coded
 ///
 /// </param>
 /// <param name="pl">The parameter list (or options).
 ///
 /// </param>
 /// <param name="cbks">Code-block size specifications
 ///
 /// </param>
 /// <param name="pss">Precinct partition specifications
 ///
 /// </param>
 /// <param name="bms">By-pass mode specifications
 ///
 /// </param>
 /// <param name="mqrs">MQ-reset specifications
 ///
 /// </param>
 /// <param name="rts">Regular termination specifications
 ///
 /// </param>
 /// <param name="css">Causal stripes specifications
 ///
 /// </param>
 /// <param name="sss">Error resolution segment symbol use specifications
 ///
 /// </param>
 /// <param name="lcs">Length computation specifications
 ///
 /// </param>
 /// <param name="tts">Termination type specifications
 ///
 /// </param>
 /// <exception cref="IllegalArgumentException">If an error occurs while parsing
 /// the options in 'pl'
 ///
 /// </exception>
 public static EntropyCoder createInstance(CBlkQuantDataSrcEnc src, ParameterList pl, CBlkSizeSpec cblks, PrecinctSizeSpec pss, StringSpec bms, StringSpec mqrs, StringSpec rts, StringSpec css, StringSpec sss, StringSpec lcs, StringSpec tts)
 {
     // Check parameters
     pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
     return(new StdEntropyCoder(src, cblks, pss, bms, mqrs, rts, css, sss, lcs, tts));
 }
Exemple #42
0
        public static Doc Print(SyntaxNode syntaxNode)
        {
            if (syntaxNode == null)
            {
                return(Doc.Null);
            }

            // TODO 0 kill? runtime repo has files that will fail on deep recursion
            if (depth > 200)
            {
                throw new InTooDeepException();
            }

            depth++;
            try
            {
                switch (syntaxNode)
                {
                case AliasQualifiedNameSyntax aliasQualifiedNameSyntax:
                    return(AliasQualifiedName.Print(aliasQualifiedNameSyntax));

                case AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax:
                    return(AnonymousMethodExpression.Print(anonymousMethodExpressionSyntax));

                case AnonymousObjectCreationExpressionSyntax anonymousObjectCreationExpressionSyntax:
                    return(AnonymousObjectCreationExpression.Print(
                               anonymousObjectCreationExpressionSyntax
                               ));

                case AnonymousObjectMemberDeclaratorSyntax anonymousObjectMemberDeclaratorSyntax:
                    return(AnonymousObjectMemberDeclarator.Print(
                               anonymousObjectMemberDeclaratorSyntax
                               ));

                case ArgumentListSyntax argumentListSyntax:
                    return(ArgumentList.Print(argumentListSyntax));

                case ArgumentSyntax argumentSyntax:
                    return(Argument.Print(argumentSyntax));

                case ArrayCreationExpressionSyntax arrayCreationExpressionSyntax:
                    return(ArrayCreationExpression.Print(arrayCreationExpressionSyntax));

                case ArrayRankSpecifierSyntax arrayRankSpecifierSyntax:
                    return(ArrayRankSpecifier.Print(arrayRankSpecifierSyntax));

                case ArrayTypeSyntax arrayTypeSyntax:
                    return(ArrayType.Print(arrayTypeSyntax));

                case ArrowExpressionClauseSyntax arrowExpressionClauseSyntax:
                    return(ArrowExpressionClause.Print(arrowExpressionClauseSyntax));

                case AssignmentExpressionSyntax assignmentExpressionSyntax:
                    return(AssignmentExpression.Print(assignmentExpressionSyntax));

                case AttributeListSyntax attributeListSyntax:
                    return(AttributeList.Print(attributeListSyntax));

                case AwaitExpressionSyntax awaitExpressionSyntax:
                    return(AwaitExpression.Print(awaitExpressionSyntax));

                case BaseExpressionSyntax baseExpressionSyntax:
                    return(BaseExpression.Print(baseExpressionSyntax));

                case BaseFieldDeclarationSyntax baseFieldDeclarationSyntax:
                    return(BaseFieldDeclaration.Print(baseFieldDeclarationSyntax));

                case BaseListSyntax baseListSyntax:
                    return(BaseList.Print(baseListSyntax));

                case BaseMethodDeclarationSyntax baseMethodDeclarationSyntax:
                    return(BaseMethodDeclaration.Print(baseMethodDeclarationSyntax));

                case BasePropertyDeclarationSyntax basePropertyDeclarationSyntax:
                    return(BasePropertyDeclaration.Print(basePropertyDeclarationSyntax));

                case BaseTypeDeclarationSyntax baseTypeDeclarationSyntax:
                    return(BaseTypeDeclaration.Print(baseTypeDeclarationSyntax));

                case BinaryExpressionSyntax binaryExpressionSyntax:
                    return(BinaryExpression.Print(binaryExpressionSyntax));

                case BinaryPatternSyntax binaryPatternSyntax:
                    return(BinaryPattern.Print(binaryPatternSyntax));

                case BlockSyntax blockSyntax:
                    return(Block.Print(blockSyntax));

                case BracketedArgumentListSyntax bracketedArgumentListSyntax:
                    return(BracketedArgumentList.Print(bracketedArgumentListSyntax));

                case BracketedParameterListSyntax bracketedParameterListSyntax:
                    return(BracketedParameterList.Print(bracketedParameterListSyntax));

                case BreakStatementSyntax breakStatementSyntax:
                    return(BreakStatement.Print(breakStatementSyntax));

                case CasePatternSwitchLabelSyntax casePatternSwitchLabelSyntax:
                    return(CasePatternSwitchLabel.Print(casePatternSwitchLabelSyntax));

                case CaseSwitchLabelSyntax caseSwitchLabelSyntax:
                    return(CaseSwitchLabel.Print(caseSwitchLabelSyntax));

                case CastExpressionSyntax castExpressionSyntax:
                    return(CastExpression.Print(castExpressionSyntax));

                case CatchClauseSyntax catchClauseSyntax:
                    return(CatchClause.Print(catchClauseSyntax));

                case CheckedExpressionSyntax checkedExpressionSyntax:
                    return(CheckedExpression.Print(checkedExpressionSyntax));

                case CheckedStatementSyntax checkedStatementSyntax:
                    return(CheckedStatement.Print(checkedStatementSyntax));

                case ClassOrStructConstraintSyntax classOrStructConstraintSyntax:
                    return(ClassOrStructConstraint.Print(classOrStructConstraintSyntax));

                case CompilationUnitSyntax compilationUnitSyntax:
                    return(CompilationUnit.Print(compilationUnitSyntax));

                case ConditionalAccessExpressionSyntax conditionalAccessExpressionSyntax:
                    return(ConditionalAccessExpression.Print(conditionalAccessExpressionSyntax));

                case ConditionalExpressionSyntax conditionalExpressionSyntax:
                    return(ConditionalExpression.Print(conditionalExpressionSyntax));

                case ConstantPatternSyntax constantPatternSyntax:
                    return(ConstantPattern.Print(constantPatternSyntax));

                case ConstructorConstraintSyntax constructorConstraintSyntax:
                    return(ConstructorConstraint.Print(constructorConstraintSyntax));

                case ConstructorInitializerSyntax constructorInitializerSyntax:
                    return(ConstructorInitializer.Print(constructorInitializerSyntax));

                case ContinueStatementSyntax continueStatementSyntax:
                    return(ContinueStatement.Print(continueStatementSyntax));

                case DeclarationExpressionSyntax declarationExpressionSyntax:
                    return(DeclarationExpression.Print(declarationExpressionSyntax));

                case DeclarationPatternSyntax declarationPatternSyntax:
                    return(DeclarationPattern.Print(declarationPatternSyntax));

                case DefaultConstraintSyntax defaultConstraintSyntax:
                    return(DefaultConstraint.Print(defaultConstraintSyntax));

                case DefaultExpressionSyntax defaultExpressionSyntax:
                    return(DefaultExpression.Print(defaultExpressionSyntax));

                case DefaultSwitchLabelSyntax defaultSwitchLabelSyntax:
                    return(DefaultSwitchLabel.Print(defaultSwitchLabelSyntax));

                case DelegateDeclarationSyntax delegateDeclarationSyntax:
                    return(DelegateDeclaration.Print(delegateDeclarationSyntax));

                case DiscardDesignationSyntax discardDesignationSyntax:
                    return(DiscardDesignation.Print(discardDesignationSyntax));

                case DiscardPatternSyntax discardPatternSyntax:
                    return(DiscardPattern.Print(discardPatternSyntax));

                case DoStatementSyntax doStatementSyntax:
                    return(DoStatement.Print(doStatementSyntax));

                case ElementAccessExpressionSyntax elementAccessExpressionSyntax:
                    return(ElementAccessExpression.Print(elementAccessExpressionSyntax));

                case ElementBindingExpressionSyntax elementBindingExpressionSyntax:
                    return(ElementBindingExpression.Print(elementBindingExpressionSyntax));

                case ElseClauseSyntax elseClauseSyntax:
                    return(ElseClause.Print(elseClauseSyntax));

                case EmptyStatementSyntax emptyStatementSyntax:
                    return(EmptyStatement.Print(emptyStatementSyntax));

                case EnumMemberDeclarationSyntax enumMemberDeclarationSyntax:
                    return(EnumMemberDeclaration.Print(enumMemberDeclarationSyntax));

                case EqualsValueClauseSyntax equalsValueClauseSyntax:
                    return(EqualsValueClause.Print(equalsValueClauseSyntax));

                case ExpressionStatementSyntax expressionStatementSyntax:
                    return(ExpressionStatement.Print(expressionStatementSyntax));

                case ExternAliasDirectiveSyntax externAliasDirectiveSyntax:
                    return(ExternAliasDirective.Print(externAliasDirectiveSyntax));

                case FinallyClauseSyntax finallyClauseSyntax:
                    return(FinallyClause.Print(finallyClauseSyntax));

                case FixedStatementSyntax fixedStatementSyntax:
                    return(FixedStatement.Print(fixedStatementSyntax));

                case ForEachStatementSyntax forEachStatementSyntax:
                    return(ForEachStatement.Print(forEachStatementSyntax));

                case ForEachVariableStatementSyntax forEachVariableStatementSyntax:
                    return(ForEachVariableStatement.Print(forEachVariableStatementSyntax));

                case ForStatementSyntax forStatementSyntax:
                    return(ForStatement.Print(forStatementSyntax));

                case FromClauseSyntax fromClauseSyntax:
                    return(FromClause.Print(fromClauseSyntax));

                case FunctionPointerTypeSyntax functionPointerTypeSyntax:
                    return(FunctionPointerType.Print(functionPointerTypeSyntax));

                case GenericNameSyntax genericNameSyntax:
                    return(GenericName.Print(genericNameSyntax));

                case GlobalStatementSyntax globalStatementSyntax:
                    return(GlobalStatement.Print(globalStatementSyntax));

                case GotoStatementSyntax gotoStatementSyntax:
                    return(GotoStatement.Print(gotoStatementSyntax));

                case GroupClauseSyntax groupClauseSyntax:
                    return(GroupClause.Print(groupClauseSyntax));

                case IdentifierNameSyntax identifierNameSyntax:
                    return(IdentifierName.Print(identifierNameSyntax));

                case IfStatementSyntax ifStatementSyntax:
                    return(IfStatement.Print(ifStatementSyntax));

                case ImplicitArrayCreationExpressionSyntax implicitArrayCreationExpressionSyntax:
                    return(ImplicitArrayCreationExpression.Print(
                               implicitArrayCreationExpressionSyntax
                               ));

                case ImplicitElementAccessSyntax implicitElementAccessSyntax:
                    return(ImplicitElementAccess.Print(implicitElementAccessSyntax));

                case ImplicitObjectCreationExpressionSyntax implicitObjectCreationExpressionSyntax:
                    return(ImplicitObjectCreationExpression.Print(
                               implicitObjectCreationExpressionSyntax
                               ));

                case ImplicitStackAllocArrayCreationExpressionSyntax implicitStackAllocArrayCreationExpressionSyntax:
                    return(ImplicitStackAllocArrayCreationExpression.Print(
                               implicitStackAllocArrayCreationExpressionSyntax
                               ));

                case IncompleteMemberSyntax incompleteMemberSyntax:
                    return(IncompleteMember.Print(incompleteMemberSyntax));

                case InitializerExpressionSyntax initializerExpressionSyntax:
                    return(InitializerExpression.Print(initializerExpressionSyntax));

                case InterpolatedStringExpressionSyntax interpolatedStringExpressionSyntax:
                    return(InterpolatedStringExpression.Print(
                               interpolatedStringExpressionSyntax
                               ));

                case InterpolatedStringTextSyntax interpolatedStringTextSyntax:
                    return(InterpolatedStringText.Print(interpolatedStringTextSyntax));

                case InterpolationSyntax interpolationSyntax:
                    return(Interpolation.Print(interpolationSyntax));

                case InvocationExpressionSyntax invocationExpressionSyntax:
                    return(InvocationExpression.Print(invocationExpressionSyntax));

                case IsPatternExpressionSyntax isPatternExpressionSyntax:
                    return(IsPatternExpression.Print(isPatternExpressionSyntax));

                case JoinClauseSyntax joinClauseSyntax:
                    return(JoinClause.Print(joinClauseSyntax));

                case LabeledStatementSyntax labeledStatementSyntax:
                    return(LabeledStatement.Print(labeledStatementSyntax));

                case LetClauseSyntax letClauseSyntax:
                    return(LetClause.Print(letClauseSyntax));

                case LiteralExpressionSyntax literalExpressionSyntax:
                    return(LiteralExpression.Print(literalExpressionSyntax));

                case LocalDeclarationStatementSyntax localDeclarationStatementSyntax:
                    return(LocalDeclarationStatement.Print(localDeclarationStatementSyntax));

                case LocalFunctionStatementSyntax localFunctionStatementSyntax:
                    return(LocalFunctionStatement.Print(localFunctionStatementSyntax));

                case LockStatementSyntax lockStatementSyntax:
                    return(LockStatement.Print(lockStatementSyntax));

                case MakeRefExpressionSyntax makeRefExpressionSyntax:
                    return(MakeRefExpression.Print(makeRefExpressionSyntax));

                case MemberAccessExpressionSyntax memberAccessExpressionSyntax:
                    return(MemberAccessExpression.Print(memberAccessExpressionSyntax));

                case MemberBindingExpressionSyntax memberBindingExpressionSyntax:
                    return(MemberBindingExpression.Print(memberBindingExpressionSyntax));

                case NameColonSyntax nameColonSyntax:
                    return(NameColon.Print(nameColonSyntax));

                case NameEqualsSyntax nameEqualsSyntax:
                    return(NameEquals.Print(nameEqualsSyntax));

                case NamespaceDeclarationSyntax namespaceDeclarationSyntax:
                    return(NamespaceDeclaration.Print(namespaceDeclarationSyntax));

                case NullableTypeSyntax nullableTypeSyntax:
                    return(NullableType.Print(nullableTypeSyntax));

                case ObjectCreationExpressionSyntax objectCreationExpressionSyntax:
                    return(ObjectCreationExpression.Print(objectCreationExpressionSyntax));

                case OmittedArraySizeExpressionSyntax omittedArraySizeExpressionSyntax:
                    return(OmittedArraySizeExpression.Print(omittedArraySizeExpressionSyntax));

                case OmittedTypeArgumentSyntax omittedTypeArgumentSyntax:
                    return(OmittedTypeArgument.Print(omittedTypeArgumentSyntax));

                case OrderByClauseSyntax orderByClauseSyntax:
                    return(OrderByClause.Print(orderByClauseSyntax));

                case ParameterListSyntax parameterListSyntax:
                    return(ParameterList.Print(parameterListSyntax));

                case ParameterSyntax parameterSyntax:
                    return(Parameter.Print(parameterSyntax));

                case ParenthesizedExpressionSyntax parenthesizedExpressionSyntax:
                    return(ParenthesizedExpression.Print(parenthesizedExpressionSyntax));

                case ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpressionSyntax:
                    return(ParenthesizedLambdaExpression.Print(
                               parenthesizedLambdaExpressionSyntax
                               ));

                case ParenthesizedPatternSyntax parenthesizedPatternSyntax:
                    return(ParenthesizedPattern.Print(parenthesizedPatternSyntax));

                case ParenthesizedVariableDesignationSyntax parenthesizedVariableDesignationSyntax:
                    return(ParenthesizedVariableDesignation.Print(
                               parenthesizedVariableDesignationSyntax
                               ));

                case PointerTypeSyntax pointerTypeSyntax:
                    return(PointerType.Print(pointerTypeSyntax));

                case PostfixUnaryExpressionSyntax postfixUnaryExpressionSyntax:
                    return(PostfixUnaryExpression.Print(postfixUnaryExpressionSyntax));

                case PredefinedTypeSyntax predefinedTypeSyntax:
                    return(PredefinedType.Print(predefinedTypeSyntax));

                case PrefixUnaryExpressionSyntax prefixUnaryExpressionSyntax:
                    return(PrefixUnaryExpression.Print(prefixUnaryExpressionSyntax));

                case PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax:
                    return(PrimaryConstructorBaseType.Print(primaryConstructorBaseTypeSyntax));

                case QualifiedNameSyntax qualifiedNameSyntax:
                    return(QualifiedName.Print(qualifiedNameSyntax));

                case QueryBodySyntax queryBodySyntax:
                    return(QueryBody.Print(queryBodySyntax));

                case QueryContinuationSyntax queryContinuationSyntax:
                    return(QueryContinuation.Print(queryContinuationSyntax));

                case QueryExpressionSyntax queryExpressionSyntax:
                    return(QueryExpression.Print(queryExpressionSyntax));

                case RangeExpressionSyntax rangeExpressionSyntax:
                    return(RangeExpression.Print(rangeExpressionSyntax));

                case RecursivePatternSyntax recursivePatternSyntax:
                    return(RecursivePattern.Print(recursivePatternSyntax));

                case RefExpressionSyntax refExpressionSyntax:
                    return(RefExpression.Print(refExpressionSyntax));

                case RefTypeExpressionSyntax refTypeExpressionSyntax:
                    return(RefTypeExpression.Print(refTypeExpressionSyntax));

                case RefTypeSyntax refTypeSyntax:
                    return(RefType.Print(refTypeSyntax));

                case RefValueExpressionSyntax refValueExpressionSyntax:
                    return(RefValueExpression.Print(refValueExpressionSyntax));

                case RelationalPatternSyntax relationalPatternSyntax:
                    return(RelationalPattern.Print(relationalPatternSyntax));

                case ReturnStatementSyntax returnStatementSyntax:
                    return(ReturnStatement.Print(returnStatementSyntax));

                case SelectClauseSyntax selectClauseSyntax:
                    return(SelectClause.Print(selectClauseSyntax));

                case SimpleBaseTypeSyntax simpleBaseTypeSyntax:
                    return(SimpleBaseType.Print(simpleBaseTypeSyntax));

                case SimpleLambdaExpressionSyntax simpleLambdaExpressionSyntax:
                    return(SimpleLambdaExpression.Print(simpleLambdaExpressionSyntax));

                case SingleVariableDesignationSyntax singleVariableDesignationSyntax:
                    return(SingleVariableDesignation.Print(singleVariableDesignationSyntax));

                case SizeOfExpressionSyntax sizeOfExpressionSyntax:
                    return(SizeOfExpression.Print(sizeOfExpressionSyntax));

                case StackAllocArrayCreationExpressionSyntax stackAllocArrayCreationExpressionSyntax:
                    return(StackAllocArrayCreationExpression.Print(
                               stackAllocArrayCreationExpressionSyntax
                               ));

                case SwitchExpressionSyntax switchExpressionSyntax:
                    return(SwitchExpression.Print(switchExpressionSyntax));

                case SwitchSectionSyntax switchSectionSyntax:
                    return(SwitchSection.Print(switchSectionSyntax));

                case SwitchStatementSyntax switchStatementSyntax:
                    return(SwitchStatement.Print(switchStatementSyntax));

                case ThisExpressionSyntax thisExpressionSyntax:
                    return(ThisExpression.Print(thisExpressionSyntax));

                case ThrowExpressionSyntax throwExpressionSyntax:
                    return(ThrowExpression.Print(throwExpressionSyntax));

                case ThrowStatementSyntax throwStatementSyntax:
                    return(ThrowStatement.Print(throwStatementSyntax));

                case TryStatementSyntax tryStatementSyntax:
                    return(TryStatement.Print(tryStatementSyntax));

                case TupleElementSyntax tupleElementSyntax:
                    return(TupleElement.Print(tupleElementSyntax));

                case TupleExpressionSyntax tupleExpressionSyntax:
                    return(TupleExpression.Print(tupleExpressionSyntax));

                case TupleTypeSyntax tupleTypeSyntax:
                    return(TupleType.Print(tupleTypeSyntax));

                case TypeArgumentListSyntax typeArgumentListSyntax:
                    return(TypeArgumentList.Print(typeArgumentListSyntax));

                case TypeConstraintSyntax typeConstraintSyntax:
                    return(TypeConstraint.Print(typeConstraintSyntax));

                case TypeOfExpressionSyntax typeOfExpressionSyntax:
                    return(TypeOfExpression.Print(typeOfExpressionSyntax));

                case TypeParameterConstraintClauseSyntax typeParameterConstraintClauseSyntax:
                    return(TypeParameterConstraintClause.Print(
                               typeParameterConstraintClauseSyntax
                               ));

                case TypeParameterListSyntax typeParameterListSyntax:
                    return(TypeParameterList.Print(typeParameterListSyntax));

                case TypeParameterSyntax typeParameterSyntax:
                    return(TypeParameter.Print(typeParameterSyntax));

                case TypePatternSyntax typePatternSyntax:
                    return(TypePattern.Print(typePatternSyntax));

                case UnaryPatternSyntax unaryPatternSyntax:
                    return(UnaryPattern.Print(unaryPatternSyntax));

                case UnsafeStatementSyntax unsafeStatementSyntax:
                    return(UnsafeStatement.Print(unsafeStatementSyntax));

                case UsingDirectiveSyntax usingDirectiveSyntax:
                    return(UsingDirective.Print(usingDirectiveSyntax));

                case UsingStatementSyntax usingStatementSyntax:
                    return(UsingStatement.Print(usingStatementSyntax));

                case VariableDeclarationSyntax variableDeclarationSyntax:
                    return(VariableDeclaration.Print(variableDeclarationSyntax));

                case VariableDeclaratorSyntax variableDeclaratorSyntax:
                    return(VariableDeclarator.Print(variableDeclaratorSyntax));

                case VarPatternSyntax varPatternSyntax:
                    return(VarPattern.Print(varPatternSyntax));

                case WhenClauseSyntax whenClauseSyntax:
                    return(WhenClause.Print(whenClauseSyntax));

                case WhereClauseSyntax whereClauseSyntax:
                    return(WhereClause.Print(whereClauseSyntax));

                case WhileStatementSyntax whileStatementSyntax:
                    return(WhileStatement.Print(whileStatementSyntax));

                case WithExpressionSyntax withExpressionSyntax:
                    return(WithExpression.Print(withExpressionSyntax));

                case YieldStatementSyntax yieldStatementSyntax:
                    return(YieldStatement.Print(yieldStatementSyntax));

                default:
                    throw new Exception("Can't handle " + syntaxNode.GetType().Name);
                }
            }

            finally
            {
                depth--;
            }
        }
Exemple #43
0
        /// <summary> Constructs a new 'ForwCompTransfSpec' for the specified number of
        /// components and tiles, the wavelet filters type and the parameter of the
        /// option 'Mct'. This constructor is called by the encoder. It also checks
        /// that the arguments belong to the recognized arguments list.
        ///
        /// <p>This constructor chose the component transformation type depending
        /// on the wavelet filters : RCT with w5x3 filter and ICT with w9x7
        /// filter. Note: All filters must use the same data type.</p>
        ///
        /// </summary>
        /// <param name="nt">The number of tiles
        ///
        /// </param>
        /// <param name="nc">The number of components
        ///
        /// </param>
        /// <param name="type">the type of the specification module i.e. tile specific,
        /// component specific or both.
        ///
        /// </param>
        /// <param name="wfs">The wavelet filter specifications
        ///
        /// </param>
        /// <param name="pl">The ParameterList
        ///
        /// </param>
        public ForwCompTransfSpec(int nt, int nc, byte type, AnWTFilterSpec wfs, ParameterList pl) : base(nt, nc, type)
        {
            System.String param = pl.getParameter("Mct");

            if (param == null)
            {
                // The option has not been specified

                // If less than three component, do not use any component
                // transformation
                if (nc < 3)
                {
                    setDefault("none");
                    return;
                }
                // If the compression is lossless, uses RCT
                else if (pl.getBooleanParameter("lossless"))
                {
                    setDefault("rct");
                    return;
                }
                else
                {
                    AnWTFilter[][] anfilt;
                    int[]          filtType = new int[nComp];
                    for (int c = 0; c < 3; c++)
                    {
                        anfilt      = (AnWTFilter[][])wfs.getCompDef(c);
                        filtType[c] = anfilt[0][0].FilterType;
                    }

                    // Check that the three first components use the same filters
                    bool reject = false;
                    for (int c = 1; c < 3; c++)
                    {
                        if (filtType[c] != filtType[0])
                        {
                            reject = true;
                        }
                    }

                    if (reject)
                    {
                        setDefault("none");
                    }
                    else
                    {
                        anfilt = (AnWTFilter[][])wfs.getCompDef(0);
                        if (anfilt[0][0].FilterType == CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7)
                        {
                            setDefault("ict");
                        }
                        else
                        {
                            setDefault("rct");
                        }
                    }
                }

                // Each tile receives a component transform specification
                // according the type of wavelet filters that are used by the
                // three first components
                for (int t = 0; t < nt; t++)
                {
                    AnWTFilter[][] anfilt;
                    int[]          filtType = new int[nComp];
                    for (int c = 0; c < 3; c++)
                    {
                        anfilt      = (AnWTFilter[][])wfs.getTileCompVal(t, c);
                        filtType[c] = anfilt[0][0].FilterType;
                    }

                    // Check that the three components use the same filters
                    bool reject = false;
                    for (int c = 1; c < nComp; c++)
                    {
                        if (filtType[c] != filtType[0])
                        {
                            reject = true;
                        }
                    }

                    if (reject)
                    {
                        setTileDef(t, "none");
                    }
                    else
                    {
                        anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, 0);
                        if (anfilt[0][0].FilterType == CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7)
                        {
                            setTileDef(t, "ict");
                        }
                        else
                        {
                            setTileDef(t, "rct");
                        }
                    }
                }
                return;
            }

            // Parse argument
            SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
            System.String          word; // current word
            byte curSpecType = SPEC_DEF; // Specification type of the

            // current parameter
            bool[] tileSpec = null; // Tiles concerned by the
                                    // specification
                                    //System.Boolean value_Renamed;

            while (stk.HasMoreTokens())
            {
                word = stk.NextToken();

                switch (word[0])
                {
                case 't':      // Tiles specification
                    tileSpec = parseIdx(word, nTiles);
                    if (curSpecType == SPEC_COMP_DEF)
                    {
                        curSpecType = SPEC_TILE_COMP;
                    }
                    else
                    {
                        curSpecType = SPEC_TILE_DEF;
                    }
                    break;

                case 'c':      // Components specification
                    throw new System.ArgumentException("Component specific " + " parameters" + " not allowed with " + "'-Mct' option");

                default:
                    if (word.Equals("off"))
                    {
                        if (curSpecType == SPEC_DEF)
                        {
                            setDefault("none");
                        }
                        else if (curSpecType == SPEC_TILE_DEF)
                        {
                            for (int i = tileSpec.Length - 1; i >= 0; i--)
                            {
                                if (tileSpec[i])
                                {
                                    setTileDef(i, "none");
                                }
                            }
                        }
                    }
                    else if (word.Equals("on"))
                    {
                        if (nc < 3)
                        {
                            throw new System.ArgumentException("Cannot use component" + " transformation on a " + "image with less than " + "three components");
                        }

                        if (curSpecType == SPEC_DEF)
                        {
                            // Set arbitrarily the default
                            // value to RCT (later will be found the suitable
                            // component transform for each tile)
                            setDefault("rct");
                        }
                        else if (curSpecType == SPEC_TILE_DEF)
                        {
                            for (int i = tileSpec.Length - 1; i >= 0; i--)
                            {
                                if (tileSpec[i])
                                {
                                    if (getFilterType(i, wfs) == CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3)
                                    {
                                        setTileDef(i, "rct");
                                    }
                                    else
                                    {
                                        setTileDef(i, "ict");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new System.ArgumentException("Default parameter of " + "option Mct not" + " recognized: " + param);
                    }

                    // Re-initialize
                    curSpecType = SPEC_DEF;
                    tileSpec    = null;
                    break;
                }
            }

            // Check that default value has been specified
            if (getDefault() == null)
            {
                // If not, set arbitrarily the default value to 'none' but
                // specifies explicitely a default value for each tile depending
                // on the wavelet transform that is used
                setDefault("none");

                for (int t = 0; t < nt; t++)
                {
                    if (isTileSpecified(t))
                    {
                        continue;
                    }

                    AnWTFilter[][] anfilt;
                    int[]          filtType = new int[nComp];
                    for (int c = 0; c < 3; c++)
                    {
                        anfilt      = (AnWTFilter[][])wfs.getTileCompVal(t, c);
                        filtType[c] = anfilt[0][0].FilterType;
                    }

                    // Check that the three components use the same filters
                    bool reject = false;
                    for (int c = 1; c < nComp; c++)
                    {
                        if (filtType[c] != filtType[0])
                        {
                            reject = true;
                        }
                    }

                    if (reject)
                    {
                        setTileDef(t, "none");
                    }
                    else
                    {
                        anfilt = (AnWTFilter[][])wfs.getTileCompVal(t, 0);
                        if (anfilt[0][0].FilterType == CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7)
                        {
                            setTileDef(t, "ict");
                        }
                        else
                        {
                            setTileDef(t, "rct");
                        }
                    }
                }
            }

            // Check validity of component transformation of each tile compared to
            // the filter used.
            for (int t = nt - 1; t >= 0; t--)
            {
                if (((System.String)getTileDef(t)).Equals("none"))
                {
                    // No comp. transf is used. No check is needed
                    continue;
                }
                else if (((System.String)getTileDef(t)).Equals("rct"))
                {
                    // Tile is using Reversible component transform
                    int filterType = getFilterType(t, wfs);
                    switch (filterType)
                    {
                    case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3:      // OK
                        break;

                    case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7:      // Must use ICT
                        if (isTileSpecified(t))
                        {
                            // User has requested RCT -> Error
                            throw new System.ArgumentException("Cannot use RCT " + "with 9x7 filter " + "in tile " + t);
                        }
                        else
                        {
                            // Specify ICT for this tile
                            setTileDef(t, "ict");
                        }
                        break;

                    default:
                        throw new System.ArgumentException("Default filter is " + "not JPEG 2000 part" + " I compliant");
                    }
                }
                else
                {
                    // ICT
                    int filterType = getFilterType(t, wfs);
                    switch (filterType)
                    {
                    case CSJ2K.j2k.wavelet.FilterTypes_Fields.W5X3:      // Must use RCT
                        if (isTileSpecified(t))
                        {
                            // User has requested ICT -> Error
                            throw new System.ArgumentException("Cannot use ICT " + "with filter 5x3 " + "in tile " + t);
                        }
                        else
                        {
                            setTileDef(t, "rct");
                        }
                        break;

                    case CSJ2K.j2k.wavelet.FilterTypes_Fields.W9X7:      // OK
                        break;

                    default:
                        throw new System.ArgumentException("Default filter is " + "not JPEG 2000 part" + " I compliant");
                    }
                }
            }
        }
        protected override string InnerTranslate()
        {
            if (this.Syntax?.Identifier.ToString() == "GetDebuggerDisplay")
            {
                return("");
            }

            if (SemicolonToken == null || SemicolonToken.IsEmpty)
            {
                return(string.Format(@"{0} {1} {2}: {3}
{4}",
                                     Modifiers.Translate(),
                                     Identifier.Translate() + TypeParameterList?.Translate() ?? "",
                                     ParameterList.Translate(),
                                     ReturnType.Translate(),
                                     Body?.Translate() ?? ";"));
            }

            string appendStr = ";";
            var    found     = (TypeDeclarationTranslation)TravelUpNotMe(f => f is TypeDeclarationTranslation);

            if (found is ClassDeclarationTranslation && found.Modifiers.IsAbstract && !this.IsOverloadedDeclaration)
            {
                appendStr = "{ throw new Error('not implemented'); }";
            }

            return($@"{GetAttributeList()}{Modifiers.Translate()} {Identifier.Translate()}{TypeParameterList?.Translate() ?? ""} {ParameterList.Translate()} : {ReturnType.Translate()}{appendStr} ");
        }
 public virtual bool Update(ParameterList pl, SunflowAPI api)
 {
     diff = pl.getColor("diffuse", diff);
     refl = pl.getFloat("shiny", refl);
     return(true);
 }
Exemple #46
0
 /// <summary> Constructs a new ForwCompTransf object that operates on the
 /// specified source of image data.
 ///
 /// </summary>
 /// <param name="imgSrc">The source from where to get the data to be
 /// transformed
 ///
 /// </param>
 /// <param name="decSpec">The decoder specifications
 ///
 /// </param>
 /// <param name="utdepth">The bit depth of the un-transformed components
 ///
 /// </param>
 /// <param name="pl">The command line optinons of the decoder
 ///
 /// </param>
 /// <seealso cref="BlkImgDataSrc">
 ///
 /// </seealso>
 public InvCompTransf(BlkImgDataSrc imgSrc, DecoderSpecs decSpec, int[] utdepth, ParameterList pl) : base(imgSrc)
 {
     this.cts     = decSpec.cts;
     this.wfs     = decSpec.wfs;
     src          = imgSrc;
     this.utdepth = utdepth;
     noCompTransf = !(pl.getBooleanParameter("comp_transf"));
 }
Exemple #47
0
 /// <summary>
 /// 序列化方法
 /// </summary>
 /// <param name="writer">2进制输出器</param>
 public void Serialize(BinaryWriter writer)
 {
     writer.Write(new UInt160());
     writer.WriteVarBytes(ParameterList.Select(p => (byte)p).ToArray());
     writer.WriteVarBytes(Script);
 }
        /// <summary> Constructs a new 'StringSpec' for the specified number of
        /// components:tiles and the arguments of <tt>optName</tt>
        /// option. This constructor is called by the encoder. It also
        /// checks that the arguments belongs to the recognized arguments
        /// list.
        ///
        /// <P><u>Note:</u> The arguments must not start with 't' or 'c'
        /// since it is reserved for respectively tile and components
        /// indexes specification.
        ///
        /// </summary>
        /// <param name="nt">The number of tiles
        ///
        /// </param>
        /// <param name="nc">The number of components
        ///
        /// </param>
        /// <param name="type">the type of the specification module i.e. tile specific,
        /// component specific or both.
        ///
        /// </param>
        /// <param name="name">of the option using boolean spec.
        ///
        /// </param>
        /// <param name="list">The list of all recognized argument in a String array
        ///
        /// </param>
        /// <param name="pl">The ParameterList
        ///
        /// </param>
        public StringSpec(int nt, int nc, byte type, System.String optName, System.String[] list, ParameterList pl) : base(nt, nc, type)
        {
            System.String param      = pl.getParameter(optName);
            bool          recognized = false;

            if (param == null)
            {
                param = pl.DefaultParameterList.getParameter(optName);
                for (int i = list.Length - 1; i >= 0; i--)
                {
                    if (param.ToUpper().Equals(list[i].ToUpper()))
                    {
                        recognized = true;
                    }
                }
                if (!recognized)
                {
                    throw new System.ArgumentException("Default parameter of " + "option -" + optName + " not" + " recognized: " + param);
                }
                setDefault(param);
                return;
            }

            // Parse argument
            SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
            System.String          word; // current word
            byte curSpecType = SPEC_DEF; // Specification type of the

            // current parameter
            bool[] tileSpec = null; // Tiles concerned by the
                                    // specification
            bool[] compSpec = null; // Components concerned by the specification
                                    //System.Boolean value_Renamed;

            while (stk.HasMoreTokens())
            {
                word = stk.NextToken();

                switch (word[0])
                {
                case 't':      // Tiles specification
                    tileSpec = parseIdx(word, nTiles);
                    if (curSpecType == SPEC_COMP_DEF)
                    {
                        curSpecType = SPEC_TILE_COMP;
                    }
                    else
                    {
                        curSpecType = SPEC_TILE_DEF;
                    }
                    break;

                case 'c':      // Components specification
                    compSpec = parseIdx(word, nComp);
                    if (curSpecType == SPEC_TILE_DEF)
                    {
                        curSpecType = SPEC_TILE_COMP;
                    }
                    else
                    {
                        curSpecType = SPEC_COMP_DEF;
                    }
                    break;

                default:
                    recognized = false;

                    for (int i = list.Length - 1; i >= 0; i--)
                    {
                        if (word.ToUpper().Equals(list[i].ToUpper()))
                        {
                            recognized = true;
                        }
                    }
                    if (!recognized)
                    {
                        throw new System.ArgumentException("Default parameter of " + "option -" + optName + " not" + " recognized: " + word);
                    }

                    if (curSpecType == SPEC_DEF)
                    {
                        setDefault(word);
                    }
                    else if (curSpecType == SPEC_TILE_DEF)
                    {
                        for (int i = tileSpec.Length - 1; i >= 0; i--)
                        {
                            if (tileSpec[i])
                            {
                                setTileDef(i, word);
                            }
                        }
                    }
                    else if (curSpecType == SPEC_COMP_DEF)
                    {
                        for (int i = compSpec.Length - 1; i >= 0; i--)
                        {
                            if (compSpec[i])
                            {
                                setCompDef(i, word);
                            }
                        }
                    }
                    else
                    {
                        for (int i = tileSpec.Length - 1; i >= 0; i--)
                        {
                            for (int j = compSpec.Length - 1; j >= 0; j--)
                            {
                                if (tileSpec[i] && compSpec[j])
                                {
                                    setTileCompVal(i, j, word);
                                }
                            }
                        }
                    }

                    // Re-initialize
                    curSpecType = SPEC_DEF;
                    tileSpec    = null;
                    compSpec    = null;
                    break;
                }
            }

            // Check that default value has been specified
            if (getDefault() == null)
            {
                int ndefspec = 0;
                for (int t = nt - 1; t >= 0; t--)
                {
                    for (int c = nc - 1; c >= 0; c--)
                    {
                        if (specValType[t][c] == SPEC_DEF)
                        {
                            ndefspec++;
                        }
                    }
                }

                // If some tile-component have received no specification, it takes
                // the default value defined in ParameterList
                if (ndefspec != 0)
                {
                    param = pl.DefaultParameterList.getParameter(optName);
                    for (int i = list.Length - 1; i >= 0; i--)
                    {
                        if (param.ToUpper().Equals(list[i].ToUpper()))
                        {
                            recognized = true;
                        }
                    }
                    if (!recognized)
                    {
                        throw new System.ArgumentException("Default parameter of " + "option -" + optName + " not" + " recognized: " + param);
                    }
                    setDefault(param);
                }
                else
                {
                    // All tile-component have been specified, takes the first
                    // tile-component value as default.
                    setDefault(getSpec(0, 0));
                    switch (specValType[0][0])
                    {
                    case SPEC_TILE_DEF:
                        for (int c = nc - 1; c >= 0; c--)
                        {
                            if (specValType[0][c] == SPEC_TILE_DEF)
                            {
                                specValType[0][c] = SPEC_DEF;
                            }
                        }
                        tileDef[0] = null;
                        break;

                    case SPEC_COMP_DEF:
                        for (int t = nt - 1; t >= 0; t--)
                        {
                            if (specValType[t][0] == SPEC_COMP_DEF)
                            {
                                specValType[t][0] = SPEC_DEF;
                            }
                        }
                        compDef[0] = null;
                        break;

                    case SPEC_TILE_COMP:
                        specValType[0][0]   = SPEC_DEF;
                        tileCompVal["t0c0"] = null;
                        break;
                    }
                }
            }
        }
Exemple #49
0
        /// <summary> Creates a new CBlkSizeSpec object for the specified number of tiles and
        /// components and the ParameterList instance.
        ///
        /// </summary>
        /// <param name="nt">The number of tiles
        ///
        /// </param>
        /// <param name="nc">The number of components
        ///
        /// </param>
        /// <param name="type">the type of the specification module i.e. tile specific,
        /// component specific or both.
        ///
        /// </param>
        /// <param name="imgsrc">The image source (used to get the image size)
        ///
        /// </param>
        /// <param name="pl">The ParameterList instance
        ///
        /// </param>
        public CBlkSizeSpec(int nt, int nc, byte type, ParameterList pl) : base(nt, nc, type)
        {
            bool firstVal = true;

            System.String param = pl.getParameter(optName);

            // Precinct partition is used : parse arguments
            SupportClass.Tokenizer stk = new SupportClass.Tokenizer(param);
            byte curSpecType           = SPEC_DEF; // Specification type of the

            // current parameter
            bool[] tileSpec = null;      // Tiles concerned by the specification
            bool[] compSpec = null;      // Components concerned by the specification
            int    ci, ti;               //  i, xIdx removed

            System.String word   = null; // current word
            System.String errMsg = null;

            while (stk.HasMoreTokens())
            {
                word = stk.NextToken();

                switch (word[0])
                {
                case 't':      // Tiles specification
                    tileSpec = parseIdx(word, nTiles);
                    if (curSpecType == SPEC_COMP_DEF)
                    {
                        curSpecType = SPEC_TILE_COMP;
                    }
                    else
                    {
                        curSpecType = SPEC_TILE_DEF;
                    }
                    break;


                case 'c':      // Components specification
                    compSpec = parseIdx(word, nComp);
                    if (curSpecType == SPEC_TILE_DEF)
                    {
                        curSpecType = SPEC_TILE_COMP;
                    }
                    else
                    {
                        curSpecType = SPEC_COMP_DEF;
                    }
                    break;


                default:
                    if (!System.Char.IsDigit(word[0]))
                    {
                        errMsg = "Bad construction for parameter: " + word;
                        throw new System.ArgumentException(errMsg);
                    }
                    System.Int32[] dim = new System.Int32[2];
                    // Get code-block's width
                    try
                    {
                        dim[0] = System.Int32.Parse(word);
                        // Check that width is not >
                        // StdEntropyCoderOptions.MAX_CB_DIM
                        if (dim[0] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
                        {
                            errMsg = "'" + optName + "' option : the code-block's " + "width cannot be greater than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM;
                            throw new System.ArgumentException(errMsg);
                        }
                        // Check that width is not <
                        // StdEntropyCoderOptions.MIN_CB_DIM
                        if (dim[0] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM)
                        {
                            errMsg = "'" + optName + "' option : the code-block's " + "width cannot be less than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM;
                            throw new System.ArgumentException(errMsg);
                        }
                        // Check that width is a power of 2
                        if (dim[0] != (1 << MathUtil.log2(dim[0])))
                        {
                            errMsg = "'" + optName + "' option : the code-block's " + "width must be a power of 2";
                            throw new System.ArgumentException(errMsg);
                        }
                    }
                    catch (System.FormatException)
                    {
                        errMsg = "'" + optName + "' option : the code-block's " + "width could not be parsed.";
                        throw new System.ArgumentException(errMsg);
                    }
                    // Get the next word in option
                    try
                    {
                        word = stk.NextToken();
                    }
                    catch (System.ArgumentOutOfRangeException)
                    {
                        errMsg = "'" + optName + "' option : could not parse the " + "code-block's height";
                        throw new System.ArgumentException(errMsg);
                    }
                    // Get the code-block's height
                    try
                    {
                        dim[1] = System.Int32.Parse(word);
                        // Check that height is not >
                        // StdEntropyCoderOptions.MAX_CB_DIM
                        if (dim[1] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM)
                        {
                            errMsg = "'" + optName + "' option : the code-block's " + "height cannot be greater than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_DIM;
                            throw new System.ArgumentException(errMsg);
                        }
                        // Check that height is not <
                        // StdEntropyCoderOptions.MIN_CB_DIM
                        if (dim[1] < CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM)
                        {
                            errMsg = "'" + optName + "' option : the code-block's " + "height cannot be less than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MIN_CB_DIM;
                            throw new System.ArgumentException(errMsg);
                        }
                        // Check that height is a power of 2
                        if (dim[1] != (1 << MathUtil.log2(dim[1])))
                        {
                            errMsg = "'" + optName + "' option : the code-block's " + "height must be a power of 2";
                            throw new System.ArgumentException(errMsg);
                        }
                        // Check that the code-block 'area' (i.e. width*height) is
                        // not greater than StdEntropyCoderOptions.MAX_CB_AREA
                        if (dim[0] * dim[1] > CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_AREA)
                        {
                            errMsg = "'" + optName + "' option : The " + "code-block's area (i.e. width*height) " + "cannot be greater than " + CSJ2K.j2k.entropy.StdEntropyCoderOptions.MAX_CB_AREA;
                            throw new System.ArgumentException(errMsg);
                        }
                    }
                    catch (System.FormatException)
                    {
                        errMsg = "'" + optName + "' option : the code-block's height " + "could not be parsed.";
                        throw new System.ArgumentException(errMsg);
                    }

                    // Store the maximum dimensions if necessary
                    if (dim[0] > maxCBlkWidth)
                    {
                        maxCBlkWidth = dim[0];
                    }

                    if (dim[1] > maxCBlkHeight)
                    {
                        maxCBlkHeight = dim[1];
                    }

                    if (firstVal)
                    {
                        // This is the first time a value is given so we set it as
                        // the default one
                        setDefault((System.Object)(dim));
                        firstVal = false;
                    }

                    switch (curSpecType)
                    {
                    case SPEC_DEF:
                        setDefault((System.Object)(dim));
                        break;

                    case SPEC_TILE_DEF:
                        for (ti = tileSpec.Length - 1; ti >= 0; ti--)
                        {
                            if (tileSpec[ti])
                            {
                                setTileDef(ti, (System.Object)(dim));
                            }
                        }
                        break;

                    case SPEC_COMP_DEF:
                        for (ci = compSpec.Length - 1; ci >= 0; ci--)
                        {
                            if (compSpec[ci])
                            {
                                setCompDef(ci, (System.Object)(dim));
                            }
                        }
                        break;

                    default:
                        for (ti = tileSpec.Length - 1; ti >= 0; ti--)
                        {
                            for (ci = compSpec.Length - 1; ci >= 0; ci--)
                            {
                                if (tileSpec[ti] && compSpec[ci])
                                {
                                    setTileCompVal(ti, ci, (System.Object)(dim));
                                }
                            }
                        }
                        break;
                    }
                    break;
                } // end switch
            }
        }
Exemple #50
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     c = pl.getColor("color", c);
     return(true);
 }
        /// <summary>
        /// Retrieves the records in the ServerMarketData that are newer than the given 'RowVersion'.
        /// </summary>
        /// <param name="RowVersion">A value which reflects the most recent record on the client.  This value will be
        /// updated by the server based on the returned DataSet and can be used for the next cycle.</param>
        /// <returns>All the records in a ServerMarketData that are newer than the given 'RowVersion'.</returns>
        public static void Reconcile(ParameterList parameters)
        {
            // Extract the client's current row version from the batch.
            long clientRowVersion = parameters["rowVersion"];

            // IMPORTANT CONCEPT: The data returned to the client is the set of rows that have been modified since the last call to
            // the 'reconcile' method.  The new data destined for the client is arranged in generic lists and arrays. This should
            // be done with structures, but the transmission of the type details of a structure over the network takes a measurable
            // amount of time.  This generic data structure of base types has the advantage of requiring less bandwidth to
            // serialize.  The big picture is that the data is passed back as an ArrayList containing essentially the table
            // information and a list of inserted, updated and deleted rows associated with each table structure.
            ArrayList reconciledData = null;

            // The "User" record of the current user is used to filter rows.
            int recordIndex = ServerMarketData.User.KeyUserUserName.Find(new object[] { System.Environment.UserName });

            if (recordIndex == -1)
            {
                throw new Exception(string.Format("The user '{0}' is not mapped to a User", System.Environment.UserName));
            }
            ServerMarketData.UserRow userRow = (ServerMarketData.UserRow)ServerMarketData.User.KeyUserUserName[recordIndex].Row;

            // The big picture is to scan through the tables looking for any row that has been modified after the 'RowVersion'
            // value passed to this method.  The 'RowVersion' acts as a one-size-fits-all state of the client data.  A generic data
            // structure will be constructed here with only the more recent records.  When the client merges this 'incremental'
            // data structure with the existing set, the server and client will be synchronized.
            foreach (Table sourceTable in ServerMarketData.Tables)
            {
                // IMPORTANT CONCEPT:  Only after we've determined that a table has new data exists will we move the schema into
                // the result set.  If there's no data in this table, it won't be initialized and a 'null' is returned to the
                // client.
                ArrayList targetRows = null;

                // IMPORTANT CONCEPT: Start scanning the table from the most recent to the eldest record.  To accomplish this, we
                // need to view the data according to 'RowVersion' (in descending order to make the loop easier to read).  While
                // the view adds a little overhead for inserting and updating, the time is more than recovered during this
                // operation.
                foreach (System.Data.DataRowView dataRowView in sourceTable.DefaultView)
                {
                    // Extract the source row from the view.  It is used several times below.
                    Row sourceRow = (Row)dataRowView.Row;

                    // This record's RowVersion will determine whether it is returned to the client or not.  Note that deleted
                    // records as well as current are included in the view and passed back to the client when appropriate.
                    long sourceRowVersion = (long)sourceRow[sourceTable.RowVersionColumn, DataRowVersion.Original];

                    // To prevent the entire table from being scanned, only the records that are newer than the client's timestamp
                    // are considered for transmission back to the client.  The default DataView on every table is organized by
                    // RowVersions, so it's safe to quit this loop when a record is older than the client's data model.
                    if (sourceRowVersion <= clientRowVersion)
                    {
                        break;
                    }

                    // All current records are compared against an optional filter and prevented from returning to the client if
                    // they are not part of what the client is authorized to view.  Some tables are public and can be shared
                    // without filters, other tables contain confidential information which is only transmitted to an entitled
                    // client.  The entitlements are generally specified by the object tree.
                    if (sourceRow.RowState != DataRowState.Deleted && sourceTable.UserFilter != null &&
                        !sourceTable.UserFilter(userRow, sourceRow))
                    {
                        continue;
                    }

                    // The bucket to hold the rows isn't created until at least one row has been discovered that needs to be
                    // returned to the client.  This is to keep the size of the returned data structure to a minimum when
                    // transmitting the incremental records.
                    if (targetRows == null)
                    {
                        // Like the bucket to hold the rows, the bucket that holds the tables -- the 'reconciledData' variable --
                        // isn't created until there is at least one table to be returned to the client.
                        if (reconciledData == null)
                        {
                            reconciledData = new ArrayList();
                        }

                        // The table-level record holds the name of the table, which will be used to look up the table on the
                        // client from the DataSet's "Table" member.  It also holds a list that contains all the records in that
                        // table.  There is one of these records for every table that has updated data that needs to be
                        // transmitted back to the client.
                        object[] targetTable = new object[2];
                        targetTable[0] = sourceTable.TableName;
                        targetTable[1] = targetRows = new ArrayList();
                        reconciledData.Add(targetTable);
                    }

                    // Deleted records are added as just the key elements.  Inserted and updated rows are added as the entire
                    // record.  The RowState is passed back to the client to tell it whether to delete, insert or update the client
                    // data model with this record.
                    targetRows.Add(new object[2] {
                        sourceRow.RowState, sourceRow.RowState == DataRowState.Deleted ?
                        DeletedRow(sourceRow) : sourceRow.ItemArray
                    });
                }
            }

            // When this data structure is merged with the client data model, the server and client databases will be in synch.  A
            // 'null' in the return data indicates that there is no data that is new since the last reconcilliation.
            parameters.Return.Value = reconciledData;
        }
Exemple #52
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     return(true);
 }
Exemple #53
0
 protected override Expression <Func <ParameterList, bool> > FindExisting(ParameterList record)
 => existing => existing.ListIdentifierId == record.ListIdentifierId;
Exemple #54
0
        public virtual bool update(ParameterList pl, SunflowAPI api)
        {
            bool updatedTopology = false;

            {
                int[] trianglesi = pl.getIntArray("triangles");
                if (trianglesi != null)
                {
                    this.triangles  = trianglesi;
                    updatedTopology = true;
                }
            }
            if (triangles == null)
            {
                UI.printError(UI.Module.GEOM, "Unable to update mesh - triangle indices are missing");
                return(false);
            }
            if (triangles.Length % 3 != 0)
            {
                UI.printWarning(UI.Module.GEOM, "Triangle index data is not a multiple of 3 - triangles may be missing");
            }
            pl.setFaceCount(triangles.Length / 3);
            {
                ParameterList.FloatParameter pointsP = pl.getPointArray("points");
                if (pointsP != null)
                {
                    if (pointsP.interp != ParameterList.InterpolationType.VERTEX)
                    {
                        UI.printError(UI.Module.GEOM, "Point interpolation type must be set to \"vertex\" - was \"{0}\"", pointsP.interp.ToString().ToLower());
                    }
                    else
                    {
                        points          = pointsP.data;
                        updatedTopology = true;
                    }
                }
            }
            if (points == null)
            {
                UI.printError(UI.Module.GEOM, "Unable to update mesh - vertices are missing");
                return(false);
            }
            pl.setVertexCount(points.Length / 3);
            pl.setFaceVertexCount(3 * (triangles.Length / 3));
            ParameterList.FloatParameter normals = pl.getVectorArray("normals");
            if (normals != null)
            {
                this.normals = normals;
            }
            ParameterList.FloatParameter uvs = pl.getTexCoordArray("uvs");
            if (uvs != null)
            {
                this.uvs = uvs;
            }
            int[] faceShaders = pl.getIntArray("faceshaders");
            if (faceShaders != null && faceShaders.Length == triangles.Length / 3)
            {
                this.faceShaders = new byte[faceShaders.Length];
                for (int i = 0; i < faceShaders.Length; i++)
                {
                    int v = faceShaders[i];
                    if (v > 255)
                    {
                        UI.printWarning(UI.Module.GEOM, "Shader index too large on triangle {0}", i);
                    }
                    this.faceShaders[i] = (byte)(v & 0xFF);
                }
            }
            if (updatedTopology)
            {
                // create triangle acceleration structure
                init();
            }
            return(true);
        }
Exemple #55
0
 public virtual bool Visit(ParameterList node)
 {
     return(CommonVisit(node));
 }
        public MainViewModel()
        {
            //var temp = JsonConvert.SerializeObject("<test>\"'/\\@#$%^&*()</asdfas>");


            TemplateText =
                @"<!-- 单属性示例 -->
Program Name: <#= P[""ProgramName""] #> 

<!-- 数组示例 -->
ConfigArray: <# foreach(var item in (P[""TestArray""] as List<string>))
        {  #> 
        - <#=item #>  <#  }  #>

<!-- 复杂数组示例 -->
ComplexArray: <# foreach(var item in (P[""ComplexArray""] as List<string>))
        { var items=item.Split(new string[] { ""|||"" }, StringSplitOptions.None);  #> 
        <config Name=""<#=items[0] #>"" Value=""<#=items[1] #>"" /> <#  }  #>

Config End;


";

            ParameterList.Add(new ParameterItem()
            {
                PropertyName = "ProgramName", PropertyValue = "TestProgramName"
            });

            var arrayParam = new ParameterItem()
            {
                PropertyName = "TestArray", DataType = "Array", PropertyValue = "AAAAA###BBBBB###CCCCC"
            };

            ParameterList.Add(arrayParam);

            var complexArray = new ParameterItem()
            {
                PropertyName = "ComplexArray", DataType = "Array", PropertyValue = "AAA|||NBB###BB|||BBB###CC|||DD"
            };

            ParameterList.Add(complexArray);

            var templateItem = new ParameterItem()
            {
                IsTemplate = true
            };

            templateItem.PropetyChangedEvent += OnTemplateItemChanged;
            ParameterList.Add(templateItem);

            RenderCommand         = new DelegateCommand <object>(OnRender);
            SaveCommand           = new DelegateCommand <object>(OnSave);
            ImportCommand         = new DelegateCommand <object>(OnImport);
            DeletePropertyCommand = new DelegateCommand <object>(obj =>
            {
                try
                {
                    if (obj is ParameterItem)
                    {
                        ParameterList.Remove(obj as ParameterItem);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            });

            if (Start.Args.Any())
            {
                ImportConfigFromFile(Start.Args.First());
            }
        }
Exemple #57
0
        /// <summary>
        /// See if the given sets of parameters match each other
        /// </summary>
        /// <param name="parameters1">The first set of parameters</param>
        /// <param name="parameters2">The second set of parameters</param>
        /// <param name="noMatchOnGenericVersions">True to fail the match if either parameter is
        /// generic, false to allow matching to generic parameters even if the other isn't.</param>
        /// <returns>True if they match, false if not</returns>
        /// <param name="allowMismatchedArrayTypes">True to allow a match with mismatched array types or false to
        /// not allow a match.  If true, we're getting pretty desperate for a match.</param>
        /// <remarks>When <paramref name="noMatchOnGenericVersions"/> is true, it prevents matching a
        /// non-generic overload of the method to a generic version of the method.  This allows the
        /// non-generic version to be matched correctly (i.e. Contains(T) and Contains(Guid)).  If not
        /// done, the generic version is matched to both methods and the reflection info contains a
        /// duplicate generic method and loses the non-generic overload.</remarks>
        private static bool ParametersMatch(ParameterList parameters1, ParameterList parameters2,
                                            bool noMatchOnGenericVersions, bool allowMismatchedArrayTypes)
        {
            if (parameters1.Count != parameters2.Count)
            {
                return(false);
            }

            for (int i = 0; i < parameters1.Count; i++)
            {
                TypeNode type1 = parameters1[i].Type;
                TypeNode type2 = parameters2[i].Type;

                // !EFW - Fail the match if we are looking for a non-generic match
                if (noMatchOnGenericVersions && (type1.IsTemplateParameter || type2.IsTemplateParameter))
                {
                    return(false);
                }

                // We can't determine the equivalence of template parameters; this is probably not good
                if (type1.IsTemplateParameter || type2.IsTemplateParameter)
                {
                    // !EFW - As a fallback, compare the type parameter positions.  If they don't match, this
                    // probably isn't the one we want.
                    int p1 = GetTemplateParameterPosition(parameters1[i].DeclaringMethod.DeclaringType, type1.Name.Name),
                        p2 = GetTemplateParameterPosition(parameters2[i].DeclaringMethod.DeclaringType, type2.Name.Name);

                    if (p1 != -1 && p2 != -1 && p1 != p2)
                    {
                        // !EFW - Another test case supplied by Jared Moore.  If the types are something like
                        // MyBaseClass<T, T> and MyBaseClass<T, U> we can still provide a match by comparing
                        // all possible positions.  As long as they intersect, it's probably a good match.
                        var positions1 = GetTemplateParameterPositions(parameters1[i].DeclaringMethod.DeclaringType,
                                                                       type1.Name.Name);
                        var positions2 = GetTemplateParameterPositions(parameters2[i].DeclaringMethod.DeclaringType,
                                                                       type2.Name.Name);

                        // If we found any but none of them are the same, then no match.
                        if (positions1.Any() && positions2.Any() && !positions1.Intersect(positions2).Any())
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    // The node type must be the same; this is probably a fast check
                    if (type1.NodeType != type2.NodeType)
                    {
                        return(false);
                    }

                    // If they are "normal" types, we will compare them.  Comparing arrays, pointers, etc. is
                    // dangerous, because the types they contain may be template parameters
                    if (type1.NodeType == NodeType.Class || type1.NodeType == NodeType.Struct ||
                        type1.NodeType == NodeType.Interface || type1.NodeType == NodeType.EnumNode ||
                        type1.NodeType == NodeType.DelegateNode)
                    {
                        type1 = type1.GetTemplateType();
                        type2 = type2.GetTemplateType();

                        if (!type2.IsStructurallyEquivalentTo(type1))
                        {
                            return(false);
                        }
                    }

                    // !EFW - Comparing array types may be dangerous but, as it turns out, is necessary.  If
                    // two overloads take an array as a parameter, it always returns the first overload as the
                    // match in derived types.  As such, we do need to compare the array element types.  For
                    // generic types, we can get the underlying template type from the declaring method's type
                    // and match that.
                    // https://github.com/EWSoftware/SHFB/issues/57
                    if (type1.NodeType == NodeType.ArrayType)
                    {
                        type1 = ((ArrayType)type1).ElementType;
                        type2 = ((ArrayType)type2).ElementType;

                        if (type2.IsTemplateParameter)
                        {
                            // Get the position from the second set of parameters
                            int pos = GetTemplateParameterPosition(parameters2[i].DeclaringMethod.DeclaringType,
                                                                   type2.Name.Name);

                            // Get the actual type from the first set of parameters
                            var declType = parameters1[i].DeclaringMethod.DeclaringType;

                            if (pos != -1 && declType.TemplateArguments != null && pos < declType.TemplateArguments.Count)
                            {
                                type2 = declType.TemplateArguments[pos];
                            }
                        }

                        if (type1.NodeType != type2.NodeType || !type2.IsStructurallyEquivalentTo(type1))
                        {
                            // !EFW - Yet another edge case to check.  In this case for example,
                            // KeyValue<int, int> didn't match KeyValue<TKey, TValue> and it failed to find any
                            // matches.  The fix is to see if both types are generic and compare the template
                            // parameter names.  This is getting rather complicated isn't it?
                            // https://github.com/EWSoftware/SHFB/issues/154
                            if (!type1.IsGeneric || !type2.IsGeneric || type1.Template == null || type2.Template == null ||
                                type1.Template.TemplateParameters.Count != type2.Template.TemplateParameters.Count ||
                                type1.Template.TemplateParameters.Select(t => t.Name.Name).Except(
                                    type2.Template.TemplateParameters.Select(t => t.Name.Name)).Any())
                            {
                                // If this is the last ditch attempt and were allowing mismatched array types,
                                // we're pretty much screwed so carry on.  This can happen in some really
                                // complex cases were we end up with an intrinsic type and a template parameter:
                                // https://github.com/EWSoftware/SHFB/issues/302
                                if (!allowMismatchedArrayTypes || type1.StructuralElementTypes == null ||
                                    type2.StructuralElementTypes == null || type1.StructuralElementTypes.Count == 0 ||
                                    type2.StructuralElementTypes.Count == 0 ||
                                    type1.StructuralElementTypes[0].IsTemplateParameter == type2.StructuralElementTypes[0].IsTemplateParameter)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
Exemple #58
0
 /// <summary>Loads a Object record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Load(ParameterList parameters)
 {
     // Accessor for the Object Table.
     ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object externalId0 = parameters["externalId0"].Value;
     object externalId1 = parameters["externalId1"].Value;
     object externalId2 = parameters["externalId2"].Value;
     object externalId3 = parameters["externalId3"].Value;
     object externalId4 = parameters["externalId4"].Value;
     object externalId5 = parameters["externalId5"].Value;
     object externalId6 = parameters["externalId6"].Value;
     object externalId7 = parameters["externalId7"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     string name = parameters["name"];
     object externalObjectId = parameters["objectId"].Value;
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int objectId = Object.FindKey(configurationId, "objectId", externalObjectId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     // The load operation will create a record if it doesn't exist, or update an existing record.  The external
     // identifier is used to determine if a record exists with the same key.
     if ((objectId == int.MinValue))
     {
         // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
         // external method is called with the same 'configurationId' parameter.
         int externalKeyIndex = Object.GetExternalKeyIndex(configurationId, "objectId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalObjectId;
         externalId0 = externalIdArray[0];
         externalId1 = externalIdArray[1];
         externalId2 = externalIdArray[2];
         externalId3 = externalIdArray[3];
         externalId4 = externalIdArray[4];
         externalId5 = externalIdArray[5];
         externalId6 = externalIdArray[6];
         externalId7 = externalIdArray[7];
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.Object.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, typeCode, worldPermission);
     }
     else
     {
         // While the optimistic concurrency checking is disabled for the external methods, the internal methods
         // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
         // will bypass the coused when the internal method is called.
         ServerDataModel.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
         rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.Object.Update(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, objectId, owner, ownerPermission, readOnly, typeCode, worldPermission);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #59
0
        /// <summary>
        /// Get the template member for the given member
        /// </summary>
        /// <param name="member">The member for which to get the template member</param>
        /// <returns>The template member for the given member.  This will be the member itself if it is not
        /// generic or it is not specialized.</returns>
        public static Member GetTemplateMember(this Member member)
        {
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            // If the containing type isn't generic, the member is the template member
            TypeNode type = member.DeclaringType;

            if (!type.IsGeneric)
            {
                return(member);
            }

            // If the containing type isn't specialized, the member is the template member
            if (!type.IsSpecialized())
            {
                return(member);
            }

            // Get the template type and look for members with the same name
            TypeNode   template   = member.DeclaringType.GetTemplateType();
            MemberList candidates = template.GetMembersNamed(member.Name);

            // If no candidates, say so (this shouldn't happen)
            if (candidates.Count == 0)
            {
                throw new InvalidOperationException("No members in the template had the name found in the " +
                                                    "specialization.  This is not possible but apparently it happened.");
            }

            // If only one candidate, return it
            if (candidates.Count == 1)
            {
                return(candidates[0]);
            }

            // Multiple candidates, so now we need to compare parameters
            ParameterList parameters = member.GetParameters();

            // !EFW - If there are no generic parameters in this method, check for an exact match
            // first ignoring all methods with generic parameters.  This prevents it matching a
            // generic overload of the method prematurely and returning the wrong one as the match.
            bool hasNoGenericParams = true;

            foreach (var p in parameters)
            {
                if (p.Type.IsTemplateParameter)
                {
                    hasNoGenericParams = false;
                    break;
                }
            }

            if (hasNoGenericParams)
            {
                for (int i = 0; i < candidates.Count; i++)
                {
                    Member candidate = candidates[i];

                    // Candidate must be same kind of node
                    if (candidate.NodeType != member.NodeType)
                    {
                        continue;
                    }

                    // Match exactly, failing if compared to a version with generic parameters
                    if (ParametersMatch(parameters, candidate.GetParameters(), true, false))
                    {
                        return(candidate);
                    }
                }
            }

            for (int i = 0; i < candidates.Count; i++)
            {
                Member candidate = candidates[i];

                // Candidate must be same kind of node
                if (candidate.NodeType != member.NodeType)
                {
                    continue;
                }

                // Allow matches to versions with generic parameters
                if (ParametersMatch(parameters, candidate.GetParameters(), false, false))
                {
                    return(candidate);
                }
            }

            // !EFW - If we get here, it's probably some really complicated signature involving multiple
            // generic types and/or mixes of intrinsic array types and generic template parameter array types.
            // So, give it one final last ditch attempt allowing intrinsic array types to match template
            // parameter array types.  If that fails, we will give up.  If there's a better way to do this, I'm
            // not aware of it.  https://github.com/EWSoftware/SHFB/issues/302
            for (int i = 0; i < candidates.Count; i++)
            {
                Member candidate = candidates[i];

                // Candidate must be same kind of node
                if (candidate.NodeType != member.NodeType)
                {
                    continue;
                }

                // Allow matches to versions with generic parameters
                if (ParametersMatch(parameters, candidate.GetParameters(), false, true))
                {
                    return(candidate);
                }
            }

            // !EFW - Due to yet another case related to generics used with array types, if we get here with no
            // matches, give up and just compare by literal type name.  If we get a match great.  If not, who
            // knows?  We'll handle any such cases as they occur.  They're very uncommon at this point anyway.
            for (int i = 0; i < candidates.Count; i++)
            {
                Member candidate = candidates[i];

                if (candidate.NodeType != member.NodeType)
                {
                    continue;
                }

                var cp = candidate.GetParameters();

                if (parameters.Count != cp.Count)
                {
                    continue;
                }

                int pi = 0;

                while (pi < parameters.Count)
                {
                    if (parameters[pi].Type.FullName != cp[pi].Type.FullName)
                    {
                        break;
                    }

                    pi++;
                }

                if (pi == parameters.Count)
                {
                    return(candidate);
                }
            }

            throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "{0}\r\n{1}\r\n" +
                                                              "No members in the template matched the parameters of the specialization.  This is not " +
                                                              "possible but apparently it happened.", member.DeclaringType.FullName, member.FullName));
        }
Exemple #60
0
 public virtual void EndVisit(ParameterList node)
 {
     CommonEndVisit(node);
 }