private static void SetByIndex(int index, long val, ParameterMode mode) { switch (mode) { case ParameterMode.Position: int tempIndex = (int)CurrentProgram[index]; Console.WriteLine(index + " " + tempIndex + " " + CurrentProgram.Count); if (CurrentProgram.Count >= tempIndex) { CurrentProgram[tempIndex] = val; } else { CurrentProgram.Insert(tempIndex, val); } break; case ParameterMode.Immediate: CurrentProgram[index] = val; break; case ParameterMode.Relative: CurrentProgram[(int)CurrentProgram[(int)index] + (int)RelativeBase] = val; break; default: Console.WriteLine("Parameter mode is not valid!"); throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } }
public ActionResult MarketingCampaignProductTracking(string Lid) { if (Lid == null) { ViewBag.Company_Code = _objCurrentInfo.GetCompanyCode(); ViewBag.Company_Id = _objCurrentInfo.GetCompanyId(); ViewBag.Region_Code = _objCurrentInfo.GetRegionCode(); ViewBag.User_Code = _objCurrentInfo.GetUserCode(); ViewBag.User_Type_Code = _objCurrentInfo.GetUserTypeCode(); ViewBag.IsResponsive = "No"; System.Web.HttpContext.Current.Session["IsResponsive"] = "No"; } else { string parameters = System.Text.ASCIIEncoding.ASCII.GetString(System.Convert.FromBase64String(Lid)); ParameterMode dd = Newtonsoft.Json.JsonConvert.DeserializeObject <ParameterMode>(parameters); ViewBag.Company_Code = dd.Company_Code; ViewBag.Company_Id = dd.Company_Id; ViewBag.Region_Code = dd.Region_Code; ViewBag.User_Code = dd.User_Code; // ViewBag.User_Type_Code = _objCurrentInfo.GetUserTypeCode(); ViewBag.IsResponsive = "Yes"; System.Web.HttpContext.Current.Session["IsResponsive"] = "Yes"; } return(View()); }
private BigInteger GetValueFromMemory(BigInteger address, ParameterMode mode) { BigInteger absoluteAddress = 0; switch (mode) { case ParameterMode.Relative: var offset = GetValueFromMemory(address, ParameterMode.Immediate); absoluteAddress = RelativeBaseAddress + offset; break; case ParameterMode.Positional: absoluteAddress = GetValueFromMemory(address, ParameterMode.Immediate); break; case ParameterMode.Immediate: absoluteAddress = address; break; } Debug.Assert(absoluteAddress >= 0); if (absoluteAddress >= Memory.Length) { return(BigMemory.ContainsKey(absoluteAddress) ? BigMemory[absoluteAddress] : 0); } else { return(Memory[(int)absoluteAddress]); } }
public int GetValueBasedOnParameterMode(int instructionPointerOffset, ParameterMode parameterMode) { return(parameterMode switch { ParameterMode.PositionMode => memory[memory[InstructionPointer + instructionPointerOffset]], ParameterMode.ImmediateMode => memory[InstructionPointer + instructionPointerOffset], _ => memory[memory[InstructionPointer + instructionPointerOffset]], });
public bool TryGetParameterMode(out ParameterMode mode) { if (IsParameterModeNull) { mode = (ParameterMode)(-1); return(false); } switch (ProcParameterMode) { case "IN": mode = ParameterMode.In; return(true); case "OUT": mode = ParameterMode.Out; return(true); case "INOUT": mode = ParameterMode.InOut; return(true); default: mode = (ParameterMode)(-1); return(false); } }
public OracleManagedQueryGenerator(ParameterMode ParameterProcessingMode) : base(':') { DataParameters = new List <OracleParameter>(); FilterParameters = new List <OracleParameter>(); this.ParameterProcessingMode = ParameterProcessingMode; command.BindByName = true; }
public void Init() { InstanceID = ~0; Bits.Clear(); TwoDPlane = TwoDPlaneEnum.XZ; PositionParameterMode = ParameterMode.OscillationByHalfLife; RotationParameterMode = ParameterMode.OscillationByHalfLife; PositionExponentialHalfLife = 0.02f; PositionOscillationHalfLife = 0.1f; PositionOscillationFrequency = 5.0f; PositionOscillationDampingRatio = 0.5f; MoveReactionMultiplier = 1.0f; LinearImpulseMultiplier = 1.0f; RotationExponentialHalfLife = 0.02f; RotationOscillationHalfLife = 0.1f; RotationOscillationFrequency = 5.0f; RotationOscillationDampingRatio = 0.5f; RotationReactionMultiplier = 1.0f; AngularImpulseMultiplier = 1.0f; }
public ItemsOrContentParameter(string itemsParameterName, string contentParameterName, ITaskItem[] items, params string[] contents) { if (items == null && contents[0] == null) { throw new ArgumentException(string.Format("One of {0} or {1} arguments must be set.", contentParameterName, itemsParameterName)); } if (items != null && contents[0] != null) { throw new ArgumentException(string.Format("Only one of {0} or {1} arguments can be set.", contentParameterName, itemsParameterName)); } if (items != null) { Data = new string[items.Length]; for (int i = 0; i < items.Length; i++) { Data[i] = items[i].ItemSpec; } _mode = ParameterMode.TaskItems; } else { Data = contents; _mode = ParameterMode.Contents; } }
private void gvDetail_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { try { SysParameter Curr_Sys = bsDetail.Current as SysParameter; if (Curr_Sys == null) { return; } ParameterMode Curr_paraMode = ParameterModes.Where(p => p.ParameterCode.Equals(Curr_Sys.ParameterCode)).FirstOrDefault(); if (Curr_paraMode == null) { return; } colParameterValue.ColumnEdit = null; if (Curr_paraMode.ExitType == 2) { string[] Items = Curr_paraMode.ChooseValues.Split(';'); RepositoryItemComboBox cbxvalue = new RepositoryItemComboBox(); cbxvalue.Appearance.Options.UseTextOptions = true; cbxvalue.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; cbxvalue.AppearanceDropDown.Options.UseTextOptions = true; cbxvalue.AppearanceDropDown.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; cbxvalue.AutoHeight = false; cbxvalue.Items.AddRange(Items); cbxvalue.Name = "cbxCarType"; cbxvalue.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; colParameterValue.ColumnEdit = cbxvalue; } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
internal void PopulateJobConfigurationQuery(JobConfigurationQuery query) { query.Query = Sql; // Safe for now; we only have "named" or "positional". This is unlikely to change. query.ParameterMode = ParameterMode.ToString().ToLowerInvariant(); query.QueryParameters = Parameters.Select(p => p.ToQueryParameter(ParameterMode)).ToList(); }
private void parseOpCode(long opCode) { A_ThirdParamMode = (ParameterMode)(opCode / 10000 % 1000 % 100 % 10); //A mode B_SecondParamMode = (ParameterMode)(opCode / 1000 % 100 % 10); //B mode C_FirstParamMode = (ParameterMode)(opCode / 100 % 10); //C mode DE_OpCode = (opCode % 100); //Opcode }
public virtual string ValueToString() { ParameterMode mode = this.Mode; if (this.Params.Count > 0) { return(this.ToStringInnerParams(null)); } string script = TokenUtils.ParseTokens(this.Value, this.Owner); if (TokenUtils.IsRawToken(script)) { mode = ParameterMode.Raw; script = TokenUtils.ReplaceRawToken(script); } else if (mode == ParameterMode.Auto) { KeyValuePair <string, ParameterMode> result = this.GetAutoValue(script); mode = result.Value; script = result.Key; } return((this.Encode ? "Ext.encode(" : "").ConcatWith( mode == ParameterMode.Raw ? script : JSON.Serialize(script), this.Encode ? ")" : "")); }
private ParameterSymbol BuildParameter(ParameterNode parameterNode, MethodSymbol methodSymbol) { ParameterMode parameterMode = ParameterMode.In; if ((parameterNode.Flags == ParameterFlags.Out) || (parameterNode.Flags == ParameterFlags.Ref)) { parameterMode = ParameterMode.InOut; } else if (parameterNode.Flags == ParameterFlags.Params) { parameterMode = ParameterMode.List; } TypeSymbol parameterType = methodSymbol.SymbolSet.ResolveType(parameterNode.Type, _symbolTable, methodSymbol); Debug.Assert(parameterType != null); if (parameterType != null) { return(new ParameterSymbol(parameterNode.Name, methodSymbol, parameterType, parameterMode)); } return(null); }
private void SetValueInMemory(BigInteger theValue, BigInteger address, ParameterMode mode) { BigInteger absoluteAddress = 0; switch (mode) { case ParameterMode.Relative: var offset = GetValueFromMemory(address, ParameterMode.Immediate); absoluteAddress = RelativeBaseAddress + offset; break; case ParameterMode.Positional: case ParameterMode.Immediate: absoluteAddress = GetValueFromMemory(address, ParameterMode.Immediate); break; } Debug.Assert(absoluteAddress >= 0); if (absoluteAddress >= Memory.Length) { BigMemory[absoluteAddress] = theValue; } else { Memory[(int)absoluteAddress] = theValue; } }
public virtual string ToString(bool camelNames) { //this.EnsureDataBind(); ParameterMode mode = this.Mode; string name = camelNames ? this.Name.ToLowerCamelCase() : this.Name; if (this.Params.Count > 0) { return(this.ToStringInnerParams(name)); } else { string script = TokenUtils.ParseTokens(this.Value, this.Owner); if (TokenUtils.IsRawToken(script)) { mode = ParameterMode.Raw; script = TokenUtils.ReplaceRawToken(script); } return(JSON.Serialize(name).ConcatWith(":", this.Encode ? "Ext.encode(" : "", mode == ParameterMode.Raw ? script : JSON.Serialize(script), this.Encode ? ")" : "")); } }
public ActionResult SingleDeviceLockRelease(string Lid = null) { // DataControl.CurrentInfo objCurInfo = new CurrentInfo(); if (Lid == null) { ViewBag.CompanyCode = _objCurrentInfo.GetCompanyCode(); ViewBag.UserCode = _objCurrentInfo.GetUserCode(); ViewBag.IsResponsive = "No"; ViewBag.subDomainName = _objCurrentInfo.GetSubDomain(); System.Web.HttpContext.Current.Session["IsResponsive"] = "No"; } else { string parameters = System.Text.ASCIIEncoding.ASCII.GetString(System.Convert.FromBase64String(Lid)); ParameterMode dd = Newtonsoft.Json.JsonConvert.DeserializeObject <ParameterMode>(parameters); ViewBag.CompanyCode = dd.Company_Code; ViewBag.subDomainName = dd.SubDomain_Name; //ViewBag.CompanyCode = dd.Company_Code; //ViewBag.RegionCode = dd.Region_Code; ViewBag.UserCode = dd.User_Code; //ViewBag.Company_Id = dd.Company_Id; ViewBag.IsResponsive = "Yes"; System.Web.HttpContext.Current.Session["IsResponsive"] = "Yes"; } return(View()); }
private void ParseParameters(long code, Instruction inst) { List <long> listOfLongs = new List <long>(); while (code > 0) { listOfLongs.Add(code % 10); code = code / 10; } _parameters = new IntCodeParameters(inst.Parameters); for (int i = 0; i < inst.Parameters; i++) { _parameters.Values.Add(Get(i + 1, ParameterMode.Immediate)); } for (int i = 2; i < listOfLongs.Count; i++) { int value = (int)listOfLongs[i]; ParameterMode m = value == 0 ? ParameterMode.Position : value == 1 ? ParameterMode.Immediate : ParameterMode.Relative; _parameters.Modes[i - 2] = m; } }
/// <summary> /// Instantiates a new encapsulated QueryGenerator object with parameter processing mode. /// </summary> public IQueryGenerator GetDbObject(ParameterMode ParameterProcessingMode) { string providerName = GetProviderName(); if (providerName == "Oracle.ManagedDataAccess.Client") { return(new OracleManagedQueryGenerator(ParameterProcessingMode)); } else if (providerName == "System.Data.SqlClient") { return(new SqlQueryGenerator(ParameterProcessingMode)); } else if (providerName == "MySql.Data.MySqlClient") { return(new MySqlQueryGenerator(ParameterProcessingMode)); } else if (providerName == "Npgsql") { return(new NpgsqlQueryGenerator(ParameterProcessingMode)); } else { throw new Exception("Provider is not recognized."); } }
public ActionResult OrderShipmentSummary(string Lid) { if (Lid == null) { ViewBag.subDomainName = _objCurrentInfo.GetSubDomain(); ViewBag.CompanyCode = _objCurrentInfo.GetCompanyCode(); ViewBag.RegionCode = _objCurrentInfo.GetRegionCode(); ViewBag.UserCode = _objCurrentInfo.GetUserCode(); ViewBag.Company_Id = _objCurrentInfo.GetCompanyId(); ViewBag.IsResponsive = "No"; System.Web.HttpContext.Current.Session["IsResponsive"] = "No"; } else { string parameters = System.Text.ASCIIEncoding.ASCII.GetString(System.Convert.FromBase64String(Lid)); ParameterMode dd = Newtonsoft.Json.JsonConvert.DeserializeObject <ParameterMode>(parameters); ViewBag.subDomainName = dd.SubDomain_Name; ViewBag.CompanyCode = dd.Company_Code; ViewBag.RegionCode = dd.Region_Code; ViewBag.UserCode = dd.User_Code; ViewBag.Company_Id = dd.Company_Id; ViewBag.IsResponsive = "Yes"; System.Web.HttpContext.Current.Session["IsResponsive"] = "Yes"; } return(View()); }
private long GetParam(long index, ParameterMode parameterMode, bool raw = false) { if (raw) { switch (parameterMode) { case ParameterMode.Position: return(GetAddressValue(_opcodeIndex + index)); case ParameterMode.Immediate: return(GetAddressValue(_opcodeIndex + index)); case ParameterMode.Relative: return(_relativeBase + GetAddressValue(_opcodeIndex + index)); default: throw new Exception($"Wrong parameter mode {parameterMode}"); } } switch (parameterMode) { case ParameterMode.Position: return(GetAddressValue(GetAddressValue(_opcodeIndex + index))); case ParameterMode.Immediate: return(GetAddressValue(_opcodeIndex + index)); case ParameterMode.Relative: return(GetAddressValue(_relativeBase + GetAddressValue(_opcodeIndex + index))); default: throw new Exception($"Wrong parameter mode {parameterMode}"); } }
private long GetParameterValue(long parameterPointer, ParameterMode parameterMode) { long position; switch (parameterMode) { case ParameterMode.Position: position = GetParameterValue(parameterPointer, ParameterMode.Immediate); break; case ParameterMode.Immediate: position = parameterPointer; break; case ParameterMode.Relative: position = GetParameterValue(parameterPointer, ParameterMode.Immediate) + _relativeBase; break; default: throw new ArgumentOutOfRangeException(nameof(parameterMode)); } if (!_memoryState.TryGetValue(position, out var value)) { _memoryState[position] = 0; value = 0; } return(value); }
private static int GetParameterValue(ParameterMode mode, List <int> sequence, int offset) { return(mode switch { ParameterMode.Position => sequence[sequence[offset]], ParameterMode.Immediate => sequence[offset], _ => throw new ArgumentException($"Unknown mode: {mode}") });
/// <summary> /// The constructor for FunctionParameter taking in a name and a TypeUsage object /// </summary> /// <param name="name"> The name of this FunctionParameter </param> /// <param name="typeUsage"> The TypeUsage describing the type of this FunctionParameter </param> /// <param name="parameterMode"> Mode of the parameter </param> /// <exception cref="System.ArgumentNullException">Thrown if name or typeUsage arguments are null</exception> /// <exception cref="System.ArgumentException">Thrown if name argument is empty string</exception> internal FunctionParameter(string name, TypeUsage typeUsage, ParameterMode parameterMode) { Check.NotEmpty(name, "name"); Check.NotNull(typeUsage, "typeUsage"); _name = name; _typeUsage = typeUsage; SetParameterMode(parameterMode); }
/// <summary> /// The constructor for FunctionParameter taking in a name and a TypeUsage object /// </summary> /// <param name="name">The name of this FunctionParameter</param> /// <param name="typeUsage">The TypeUsage describing the type of this FunctionParameter</param> /// <param name="parameterMode">Mode of the parameter</param> /// <exception cref="System.ArgumentNullException">Thrown if name or typeUsage arguments are null</exception> /// <exception cref="System.ArgumentException">Thrown if name argument is empty string</exception> internal FunctionParameter(string name, TypeUsage typeUsage, ParameterMode parameterMode) { EntityUtil.CheckStringArgument(name, "name"); EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage"); _name = name; _typeUsage = typeUsage; SetParameterMode(parameterMode); }
internal FunctionParameter(string name, TypeUsage typeUsage, ParameterMode parameterMode) { Check.NotEmpty(name, nameof(name)); Check.NotNull <TypeUsage>(typeUsage, nameof(typeUsage)); this._name = name; this._typeUsage = typeUsage; this.SetParameterMode(parameterMode); }
private static int Get(IList <int> codes, int pos, ParameterMode mode) { return(mode switch { ParameterMode.Position => codes[codes[pos]], ParameterMode.Immediate => codes[pos], _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null) });
internal void ModifyRequest(JobConfigurationQuery query) { // Note: no validation of combinations (flatten results etc). Leave this to the server, // to avoid restrictions getting out of date. if (AllowLargeResults != null) { query.AllowLargeResults = AllowLargeResults; } if (CreateDisposition != null) { query.CreateDisposition = EnumMap.ToApiValue(CreateDisposition.Value); } if (DefaultDataset != null) { query.DefaultDataset = DefaultDataset; } if (DestinationTable != null) { query.DestinationTable = DestinationTable; } if (FlattenResults != null) { query.FlattenResults = FlattenResults; } if (MaximumBillingTier != null) { query.MaximumBillingTier = MaximumBillingTier; } if (MaximumBytesBilled != null) { query.MaximumBytesBilled = MaximumBytesBilled; } if (Priority != null) { query.Priority = EnumMap.ToApiValue(Priority.Value); } if (UseQueryCache != null) { query.UseQueryCache = UseQueryCache; } if (WriteDisposition != null) { query.WriteDisposition = EnumMap.ToApiValue(WriteDisposition.Value); } if (UseLegacySql != null) { query.UseLegacySql = UseLegacySql; } if (ParameterMode != null) { // Safe for now; we only have "named" or "positional". This is unlikely to change. query.ParameterMode = ParameterMode.ToString().ToLowerInvariant(); } if (DestinationEncryptionConfiguration != null) { query.DestinationEncryptionConfiguration = DestinationEncryptionConfiguration; } }
private void Write(int position, int value, ParameterMode mode) { if (mode == ParameterMode.Position) { position = Read(position, ParameterMode.Immediate); } _opcodes[position] = value; }
public Instruction(long instructionValue) { instructionString = instructionValue.ToString("D5"); OpCode = (IntCodeOpCode)int.Parse(instructionString.Substring(3, 2)); FirstParameterMode = (ParameterMode)int.Parse(instructionString.Substring(2, 1)); SecondParameterMode = (ParameterMode)int.Parse(instructionString.Substring(1, 1)); ThirdParameterMode = (ParameterMode)int.Parse(instructionString.Substring(0, 1)); }
private static int GetValue(IReadOnlyList <int> codes, int parameter, ParameterMode mode) { if (mode == ParameterMode.Immediate) { return(parameter); } return(codes[parameter]); }
/// <summary> /// Creates a SharpHsqlParameter given a name, type, and direction /// </summary> internal static SharpHsqlParameter CreateSqlParameter(string name, TypeUsage type, ParameterMode mode, object value) { int? size; SharpHsqlParameter result = new SharpHsqlParameter(name, value); // .Direction ParameterDirection direction = MetadataHelpers.ParameterModeToParameterDirection(mode); if (result.Direction != direction) { result.Direction = direction; } // .Size and .DbType // output parameters are handled differently (we need to ensure there is space for return // values where the user has not given a specific Size/MaxLength) bool isOutParam = mode != ParameterMode.In; DbType sqlDbType = GetSqlDbType(type, isOutParam, out size); if (result.DbType != sqlDbType) { result.DbType = sqlDbType; } // Note that we overwrite 'facet' parameters where either the value is different or // there is an output parameter. if (size.HasValue && (isOutParam || result.Size != size.Value)) { result.Size = size.Value; } // .IsNullable bool isNullable = MetadataHelpers.IsNullable(type); if (isOutParam || isNullable != result.IsNullable) { result.IsNullable = isNullable; } return result; }
/// <summary> /// Creates a SqlParameter given a name, type, and direction /// </summary> internal static CrmParameter CreateParameter(string name, TypeUsage type, ParameterMode mode, object value) { // int? size; value = EnsureParameterValue(value); CrmParameter result = new CrmParameter(name, value); throw new NotImplementedException(); //// .Direction //result.Direction = MetadataHelpers.ParameterModeToParameterDirection(mode); //// .Size and .SqlDbType //// output parameters are handled differently (we need to ensure there is space for return //// values where the user has not given a specific Size/MaxLength) //bool isOutParam = mode != ParameterMode.In; //string udtTypeName; //result.DbType = GetSqlDbType(type, isOutParam, out size, out udtTypeName); //result.UdtTypeName = udtTypeName; //// Note that we overwrite 'facet' parameters where either the value is different or //// there is an output parameter. //if (size.HasValue && (isOutParam || result.Size != size.Value)) //{ // result.Size = size.Value; //} //// .IsNullable //bool isNullable = MetadataHelpers.IsNullable(type); //if (isOutParam || isNullable != result.IsNullable) //{ // result.IsNullable = isNullable; //} //return result; }
internal static NuoDbParameter CreateSqlParameter(string name, TypeUsage type, ParameterMode mode, object value) { NuoDbParameter result = new NuoDbParameter(); result.ParameterName = name; result.Value = value; ParameterDirection direction = MetadataHelpers.ParameterModeToParameterDirection(mode); if (result.Direction != direction) { result.Direction = direction; } // output parameters are handled differently (we need to ensure there is space for return // values where the user has not given a specific Size/MaxLength) bool isOutParam = mode != ParameterMode.In; bool isNullable = MetadataHelpers.IsNullable(type); if (isOutParam || isNullable != result.IsNullable) { result.IsNullable = isNullable; } return result; }
/// <summary> /// Creates a SqlParameter given a name, type, and direction /// </summary> internal static SqlParameter CreateSqlParameter(string name, TypeUsage type, ParameterMode mode, object value, bool preventTruncation, SqlVersion version) { int? size; byte? precision; byte? scale; string udtTypeName; value = EnsureSqlParameterValue(value); SqlParameter result = new SqlParameter(name, value); // .Direction ParameterDirection direction = MetadataHelper.ParameterModeToParameterDirection(mode); if (result.Direction != direction) { result.Direction = direction; } // .Size, .Precision, .Scale and .SqlDbType // output parameters are handled differently (we need to ensure there is space for return // values where the user has not given a specific Size/MaxLength) bool isOutParam = mode != ParameterMode.In; SqlDbType sqlDbType = GetSqlDbType(type, isOutParam, version, out size, out precision, out scale, out udtTypeName); if (result.SqlDbType != sqlDbType) { result.SqlDbType = sqlDbType; } if (sqlDbType == SqlDbType.Udt) { result.UdtTypeName = udtTypeName; } // Note that we overwrite 'facet' parameters where either the value is different or // there is an output parameter. This is because output parameters in SqlClient have their // facets clobbered if they are implicitly set (e.g. if the Size was implicitly set // by setting the value) if (size.HasValue) { // size.HasValue is always true for Output parameters if ((isOutParam || result.Size != size.Value)) { if (preventTruncation && size.Value != -1) { // To prevent truncation, set the Size of the parameter to the larger of either // the declared length or the actual length for the parameter. This allows SQL // Server to complain if a value is too long while preventing cache misses for // values within the range. result.Size = Math.Max(result.Size, size.Value); } else { result.Size = size.Value; } } } else { PrimitiveTypeKind typeKind = MetadataHelper.GetPrimitiveTypeKind(type); if (typeKind == PrimitiveTypeKind.String) { result.Size = GetDefaultStringMaxLength(version, sqlDbType); } else if(typeKind == PrimitiveTypeKind.Binary) { result.Size = GetDefaultBinaryMaxLength(version); } } if (precision.HasValue && (isOutParam || result.Precision != precision.Value)) { result.Precision = precision.Value; } if (scale.HasValue && (isOutParam || result.Scale != scale.Value)) { result.Scale = scale.Value; } // .IsNullable bool isNullable = TypeSemantics.IsNullable(type); if (isOutParam || isNullable != result.IsNullable) { result.IsNullable = isNullable; } return result; }
/// <summary> /// The factory method for constructing the <see cref="FunctionParameter" /> object. /// </summary> /// <param name="name">The name of the parameter.</param> /// <param name="edmType">The EdmType of the parameter.</param> /// <param name="parameterMode"> /// The <see cref="ParameterMode" /> of the parameter. /// </param> /// <returns> /// A new, read-only instance of the <see cref="EdmFunction" /> type. /// </returns> public static FunctionParameter Create(string name, EdmType edmType, ParameterMode parameterMode) { Check.NotEmpty(name, "name"); Check.NotNull(edmType, "edmType"); var functionParameter = new FunctionParameter(name, TypeUsage.Create(edmType, FacetValues.NullFacetValues), parameterMode); functionParameter.SetReadOnly(); return functionParameter; }
//=========================================================================================== private void WriteParameterTypes(IndentedTextWriter writer, MethodBase method, ParameterMode mode) { ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length == 0) return; if (mode.HasFlag(ParameterMode.AddColon)) writer.Write(", "); writer.Write("new Type[] {"); for (int i = 0; i < parameters.Length; i++) { if (i > 0) writer.Write(", "); Type type = GetIEnumerable(parameters[i]); if (type != null) { writer.Write("Types.IEnumerable"); WriteType(writer, type); } else { WriteTypeOf(writer, parameters[i].ParameterType); } } writer.Write("}"); }
private static void TryGetParameterMode_test_helper(object paramDirection, bool successExpected, ParameterMode expectedMode) { var row = new[] { "schema", "name", "retType", null, null, null, null, "paramName", "paramType", paramDirection }; ParameterMode actualMode; var success = new FunctionDetailsV1RowView(row).TryGetParameterMode(out actualMode); Assert.Equal(successExpected, success); Assert.Equal(expectedMode, actualMode); }
public Parameter(string name, string value, ParameterMode mode, bool encode) : base(name, value, mode, encode) { }
private static FunctionParameter CreatePrimitiveParameter(string name, PrimitiveTypeKind type, ParameterMode mode) { return FunctionParameter.Create( name, ProviderManifest.GetStoreType( TypeUsage.CreateDefaultTypeUsage( PrimitiveType.GetEdmPrimitiveType(type))).EdmType, mode); }
internal void SetParameterMode(ParameterMode mode) { _flags = (_flags & ~MetadataFlags.ParameterMode) | (MetadataFlags.ParameterMode & Convert(mode)); }
private static SqlParameter CreateDecimalParameter(byte precision, byte scale, ParameterMode parameterMode) { return SqlProviderServices.CreateSqlParameter( "Lily", TypeUsage.CreateDecimalTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Decimal), precision, scale), parameterMode, 99999999.88888888m, true, SqlVersion.Sql11); }
private static MetadataFlags Convert(ParameterMode mode) { switch (mode) { default: return MetadataFlags.ParameterMode; // invalid case ParameterMode.In: return MetadataFlags.In; case ParameterMode.Out: return MetadataFlags.Out; case ParameterMode.InOut: return MetadataFlags.InOut; case ParameterMode.ReturnValue: return MetadataFlags.ReturnValue; } }
public ParameterSymbol(string name, MemberSymbol parent, TypeSymbol valueType, ParameterMode mode) : base(SymbolType.Parameter, name, parent, valueType) { _mode = mode; }
// Returns ParameterDirection corresponding to given ParameterMode private static ParameterDirection ParameterModeToParameterDirection(ParameterMode mode) { switch (mode) { case ParameterMode.In: return ParameterDirection.Input; case ParameterMode.InOut: return ParameterDirection.InputOutput; case ParameterMode.Out: return ParameterDirection.Output; case ParameterMode.ReturnValue: return ParameterDirection.ReturnValue; default: Debug.Fail("unrecognized mode " + mode.ToString()); return default(ParameterDirection); } }
//=========================================================================================== private void WriteParameters(IndentedTextWriter writer, ParameterMode mode, params ParameterInfo[] parameters) { for (int i = 0; i < parameters.Length; i++) { if (i > 0 || mode.HasFlag(ParameterMode.AddColon)) writer.Write(", "); if (mode.HasFlag(ParameterMode.Type)) { if (parameters[i].GetCustomAttribute<ParamArrayAttribute>() != null) writer.Write("params "); WriteType(writer, parameters[i].ParameterType); writer.Write(" "); } if (mode.HasFlag(ParameterMode.Instance) && (_Types.Contains(parameters[i].ParameterType) || parameters[i].ParameterType == typeof(object))) { WriteType(writer, parameters[i]); writer.Write(".GetInstance("); writer.Write(parameters[i].Name); writer.Write(")"); } else { if (mode.HasFlag(ParameterMode.Instance)) { if (WriteIEnumerableParameter(writer, parameters[i])) continue; } if (!mode.HasFlag(ParameterMode.Type) && mode.HasFlag(ParameterMode.Name) && IsArray(parameters[i].ParameterType)) writer.Write("casted_"); writer.Write(parameters[i].Name); } } }
/// <summary> /// Creates a SQLiteParameter given a name, type, and direction /// </summary> internal static SQLiteParameter CreateSqlParameter(SQLiteProviderManifest manifest, string name, TypeUsage type, ParameterMode mode, object value) { int? size; // // NOTE: Adjust the parameter type so that it will work with textual // GUIDs. Please see ticket [a4d9c7ee94] for more details. // if ((manifest != null) && !manifest._binaryGuid && (MetadataHelpers.GetPrimitiveTypeKind(type) == PrimitiveTypeKind.Guid)) { type = TypeUsage.CreateStringTypeUsage( PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, true); } SQLiteParameter result = new SQLiteParameter(name, value); // .Direction ParameterDirection direction = MetadataHelpers.ParameterModeToParameterDirection(mode); if (result.Direction != direction) { result.Direction = direction; } // .Size and .DbType // output parameters are handled differently (we need to ensure there is space for return // values where the user has not given a specific Size/MaxLength) bool isOutParam = mode != ParameterMode.In; DbType sqlDbType = GetSqlDbType(type, isOutParam, out size); if (result.DbType != sqlDbType) { result.DbType = sqlDbType; } // Note that we overwrite 'facet' parameters where either the value is different or // there is an output parameter. if (size.HasValue && (isOutParam || result.Size != size.Value)) { result.Size = size.Value; } // .IsNullable bool isNullable = MetadataHelpers.IsNullable(type); if (isOutParam || isNullable != result.IsNullable) { result.IsNullable = isNullable; } return result; }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="mode"></param> public StoreParameter(string name, string value, ParameterMode mode) : base(name, value, mode) { }
protected BaseParameter(string name, string value, ParameterMode mode, bool encode) : this(name, value) { this.Mode = mode; this.Encode = encode; }
//=========================================================================================== private void WriteParameters(IndentedTextWriter writer, MethodBase method, ParameterMode mode) { WriteParameters(writer, mode, method.GetParameters()); }