internal static Result<CodeNamespace> Process(string xsdFile, string targetNamespace, GenerationLanguage language, CollectionType collectionType, bool enableDataBinding, bool hidePrivate, bool enableSummaryComment, List<NamespaceParam> customUsings, string collectionBase, bool includeSerializeMethod, string serializeMethodName, string deserializeMethodName, string saveToFileMethodName, string loadFromFileMethodName, bool generateCloneMethod, TargetFramework targetFramework) { var generatorParams = new GeneratorParams { CollectionObjectType = collectionType, EnableDataBinding = enableDataBinding, Language = language, CustomUsings = customUsings, CollectionBase = collectionBase, GenerateCloneMethod = generateCloneMethod, TargetFramework = targetFramework }; generatorParams.Miscellaneous.HidePrivateFieldInIde = hidePrivate; generatorParams.Miscellaneous.EnableSummaryComment = enableSummaryComment; generatorParams.Serialization.Enabled = includeSerializeMethod; generatorParams.Serialization.SerializeMethodName = serializeMethodName; generatorParams.Serialization.DeserializeMethodName = deserializeMethodName; generatorParams.Serialization.SaveToFileMethodName = saveToFileMethodName; generatorParams.Serialization.LoadFromFileMethodName = loadFromFileMethodName; return Process(generatorParams); }
protected GameCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art) { Engine = engine; Theater = theater; Type = type; Rules = rules; Art = art; }
private void ListTest(CollectionType collectionType) { try { var ma = CollectionFactory.CreateAList<int>(collectionType, 10); ma.Insert(5, 0); ma.Insert(10, 1); ma.Insert(15, 2); int a = ma.Get(0); int b = ma.Get(1); int c = ma.Get(2); Assert.AreEqual(a, 5); Assert.AreEqual(b, 10); Assert.AreEqual(c, 15); ma.Remove(1); a = ma.Get(1); Assert.AreEqual(a, 15); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Assert.AreEqual(0, 1); } }
/// <summary> /// Constructor /// </summary> /// <param name="collection">Wether the field is a collection</param> /// <param name="name">Name of the field</param> /// <param name="description">Description for the field, used for commenting</param> /// <param name="optional">Whether the field is optionable \ nullable</param> /// <param name="minimumValue">The minimum acceptable value for this property</param> /// <param name="maximumValue">The maximum acceptable value for this property</param> /// <param name="isKey"> /// Whether the property is the primary key /// </param> /// <param name="alternativeDatabaseColumnName"> /// Name of the database column name, if it's different from the .NET property name. /// </param> public ClrDateTimePropertyInfo( CollectionType collection, System.String name, System.String description, bool optional, System.DateTime? minimumValue, System.DateTime? maximumValue, bool isKey, string alternativeDatabaseColumnName) : base(collection, name, description, optional, "System.DateTime", "Dhgms.DataManager.Model.SearchFilter.DateTime", "DateTime", false, "System.DateTime.MinValue", false, isKey, true, typeof(System.DateTime), alternativeDatabaseColumnName) { this.minimumValue = minimumValue; this.maximumValue = maximumValue; }
/// <summary> /// Initializes a new instance of the <see cref="ClrBytePropertyInfo"/> class. /// </summary> /// <param name="collection">Whether the field is a collection</param> /// <param name="name">Name of the field</param> /// <param name="description">Description for the field, used for commenting</param> /// <param name="optional">Whether the field is optional \ capable of being null</param> /// <param name="minimumValue">The minimum acceptable value for this property</param> /// <param name="maximumValue">The maximum acceptable value for this property</param> /// <param name="isKey"> /// Whether the property is the primary key /// </param> /// <param name="alternativeDatabaseColumnName"> /// Name of the database column name, if it's different from the .NET property name. /// </param> public ClrBytePropertyInfo( CollectionType collection, string name, string description, bool optional, byte? minimumValue, byte? maximumValue, bool isKey, string alternativeDatabaseColumnName) : base( collection, name, description, optional, "byte", "Dhgms.DataManager.Model.SearchFilter.Byte", "Byte", false, "0", false, isKey, true, typeof(byte), alternativeDatabaseColumnName) { this.minimumValue = minimumValue; this.maximumValue = maximumValue; }
void fillListView(CollectionType<Tor> torCollection) { //foreach (Tor value in torCollection) MessageBox.Show(value.ToString()); InitializeList(); try { //for (int i = 0; i < torCollection.Count; i++) listView1.Columns.Add("Имя", listView1.Width / 3); listView1.Columns.Add("Внутренний радиус", listView1.Width / 3); listView1.Columns.Add("Внешний радиус", listView1.Width / 3); for (int i = 0; i < torCollection.Count; i++) { ListViewItem row = new ListViewItem(torCollection.ElementAt(i).Name); row.SubItems.Add(torCollection.ElementAt(i).innerRadius.ToString()); row.SubItems.Add(torCollection.ElementAt(i).outerRadius.ToString()); listView1.Items.Add(row); } } catch(Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="ClrStringPropertyInfo"/> class. /// Constructor /// </summary> /// <param name="collection"> /// Wether the field is a collection /// </param> /// <param name="name"> /// Name of the field /// </param> /// <param name="description"> /// Description for the field, used for commenting /// </param> /// <param name="optional"> /// Whether the field is optionable \ nullable /// </param> /// <param name="minimumLength"> /// The minimum acceptable length for a string /// </param> /// <param name="maximumLength"> /// The maximum acceptable length for a string /// </param> /// <param name="isKey"> /// Whether the property is the primary key /// </param> /// <param name="xmlIsCdataElement"> /// The xml element produced is a CDATA Element. /// </param> /// <param name="alternativeDatabaseColumnName"> /// Name of the database column name, if it's different from the .NET property name. /// </param> public ClrStringPropertyInfo( CollectionType collection, string name, string description, bool optional, int? minimumLength, int? maximumLength, bool isKey, bool xmlIsCdataElement, string alternativeDatabaseColumnName) : base(collection, name, description, optional, "string", "Dhgms.DataManager.Model.SearchFilter.String", "String", false, "null", false, isKey, xmlIsCdataElement, typeof(string), alternativeDatabaseColumnName) { this.MinimumLength = minimumLength; this.MaximumLength = maximumLength; }
private static string ToStringType(CollectionType collectionType) { if (collectionType == CollectionType.Series) { return "series"; } return "set"; }
public ArangoResponse<JObject> Create(string collection, CollectionType type = CollectionType.Document, string database = null) { return Dispatcher.Send(new CreateCollection { Database = GetDatabase(database), Collection = collection, Type = type }); }
public XmlDocument CreatePivotCollectionForList(string collectionName, string photoList, CollectionType type, string subsetName = null) { using (SqlConnection conn = new SqlConnection(_connectionString)) { conn.Open(); using (SqlCommand command = new SqlCommand(string.Format("select ID, Captured, Site_ID from Photos where Photos.ID IN ({0})", photoList), conn)) { return CreatePivotDocument(collectionName, command, null, type, subsetName); } } }
static string GetParentClass (CollectionType t) { switch (t) { case CollectionType.Int32: case CollectionType.Double: case CollectionType.Point: case CollectionType.Vector: return "Freezable"; default: return "Animatable"; } }
public BookCollection(string path, CollectionType collectionType, BookSelection bookSelection) { _path = path; _bookSelection = bookSelection; Type = collectionType; if (collectionType == CollectionType.TheOneEditableCollection) { MakeCollectionCSSIfMissing(); } }
public static bool GetFlatnessAssumption(CollectionType t) { switch (t) { case CollectionType.Overlay: case CollectionType.Smudge: return true; case CollectionType.Building: case CollectionType.Aircraft: case CollectionType.Infantry: case CollectionType.Terrain: case CollectionType.Vehicle: return false; default: return true; } }
static bool HasConverter (CollectionType t) { switch (t) { case CollectionType.Drawing: case CollectionType.Geometry: case CollectionType.PathSegment: case CollectionType.GradientStop: case CollectionType.GeneralTransform: case CollectionType.Transform: case CollectionType.Timeline: return false; default: return true; } }
/// <summary> /// Initializes a new instance of the <see cref="TriState"/> class. /// Constructor /// </summary> /// <param name="collection"> /// Wether the field is a collection /// </param> /// <param name="name"> /// Name of the field /// </param> /// <param name="description"> /// Description for the field, used for commenting /// </param> /// <param name="optional"> /// Whether the field is optionable \ nullable /// </param> /// <param name="isKey"> /// Whether the property is the primary key /// </param> public TriState(CollectionType collection, string name, string description, bool optional, bool isKey) : base(collection, name, description, optional, "Dhgms.DataManager.Model.Info.TriState", "Dhgms.DataManager.Model.SearchFilter.TriState", "Byte", true, "Dhgms.DataManager.Model.Info.TriState.Unknown", false, isKey, true) { }
private int upperIndexTextInView = 4; //the upper index of the texts currently being displayed (or will be display) #endregion Fields #region Constructors //private TextMessageOptions.CollectionType collectionType; //constructor public TextMessageCollection(string incomingFileName, CollectionType type) { fileName = incomingFileName; //int intType = (int)type; collectionType = type; cc = ps.cc; if (fileName != "") { fileData = FileManager.Load (fileName); LoadSavedTexts (); SetUpperIndexTextInViewToTop (); } }
// Methods public CollectionPatternGenerator(string typeName) { this.m_Usings = new ArrayList(); this.ClassPrefix = string.Empty; this.FileName = string.Empty; this.TestFileName = string.Empty; this.NameSpace = "Grepton.Runtime"; this.Type = CollectionType.Collection; this.UsingInTest = string.Empty; this.TestInit1 = string.Empty; this.TestInit2 = string.Empty; this.TestInit3 = string.Empty; this.TestInit4 = string.Empty; this.TestInit5 = string.Empty; this.m_TypeName = typeName; }
public static bool GetDefaultRemappability(CollectionType type, EngineType engine) { switch (type) { case CollectionType.Aircraft: case CollectionType.Building: case CollectionType.Infantry: case CollectionType.Vehicle: return true; case CollectionType.Overlay: case CollectionType.Smudge: case CollectionType.Terrain: case CollectionType.Animation: return false; default: throw new ArgumentOutOfRangeException("type"); } }
internal static LightingType GetDefaultLighting(CollectionType type) { switch (type) { case CollectionType.Aircraft: case CollectionType.Building: case CollectionType.Infantry: case CollectionType.Vehicle: return LightingType.Ambient; case CollectionType.Overlay: case CollectionType.Smudge: case CollectionType.Terrain: case CollectionType.Animation: return LightingType.Full; default: throw new ArgumentOutOfRangeException("type"); } }
// Managed at: // https://docs.google.com/spreadsheet/ccc?key=0AiVQdoAJ4w7bdE9ILUpvNVVDa2J2MG04RnBURU96VUE#gid=0 public static PaletteType GetDefaultPalette(CollectionType t, EngineType engine) { switch (t) { case CollectionType.Building: case CollectionType.Aircraft: case CollectionType.Infantry: case CollectionType.Vehicle: return PaletteType.Unit; case CollectionType.Overlay: return PaletteType.Overlay; case CollectionType.Smudge: case CollectionType.Terrain: case CollectionType.Animation: default: return PaletteType.Iso; } }
public GeneratorFacade(string inputFile, string nameSpace, GenerationLanguage language, CollectionType collectionType, bool enableDataBinding, bool hidePrivate, bool enableSummaryComment, List<NamespaceParam> customUsings, string collectionBase, bool includeSerializeMethod, string serializeMethodName, string deserializeMethodName, string saveToFileMethodName, string loadFromFileMethodName, bool disableDebug, bool implementCloneMethod, TargetFramework targetFramework) { var provider = CodeDomProviderFactory.GetProvider(language); this.Init(inputFile, nameSpace, provider, collectionType, enableDataBinding, hidePrivate, enableSummaryComment, customUsings, collectionBase, includeSerializeMethod, serializeMethodName, deserializeMethodName, saveToFileMethodName, loadFromFileMethodName, disableDebug, implementCloneMethod, targetFramework); }
public ObjectCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art, IniFile.IniSection objectsList, PaletteCollection palettes) : base(type, theater, engine, rules, art) { Palettes = palettes; if (engine >= EngineType.RedAlert2) { string fireNames = Rules.ReadString(Engine == EngineType.RedAlert2 ? "AudioVisual" : "General", "DamageFireTypes", "FIRE01,FIRE02,FIRE03"); FireNames = fireNames.Split(new[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries); } foreach (var entry in objectsList.OrderedEntries) { if (!string.IsNullOrEmpty(entry.Value)) { Logger.Trace("Loading object {0}.{1}", objectsList.Name, entry.Value); AddObject(entry.Value); } } }
public PerformanceResult ExecCollectionTest(CollectionType collectionType) { CollType = collectionType; Action<object> a = new Action<object>(x => { short threadNo = short.Parse(x.ToString()); Debug.WriteLine("Start creation of 10k ints..."); //Add 10000 ints for(int i = 0;i<10000;i++) { //Increase the next integer with 1 //To test reading/saving from multi threaded environment switch (collectionType) { case CollectionType.List: if (ListTest.Count > 0) ListTest.Add(new KeyValuePair<int, short>((ListTest[(ListTest.Count - 1)].Key + 1), threadNo)); else ListTest.Add(new KeyValuePair<int, short>(i, threadNo)); break; default: throw new NotImplementedException(); } } Debug.WriteLine("Finished creation of 10k ints..."); }); Action b = new Action(() => { Task[] tasks = new Task[3] { Task.Factory.StartNew(a, 1), Task.Factory.StartNew(a, 2), Task.Factory.StartNew(a, 3) }; Task.WaitAll(tasks); Debug.WriteLine("List count: " + CollectionCount.ToString()); }); long elapsedTime = Utils.Utils.MeasureElapsedTime(b); return new PerformanceResult(elapsedTime, ListTest); }
public void QueueTest(CollectionType collectionType){ try { var queue = CollectionFactory.CreateAQueue<int>(collectionType,10); queue.Enqueue(5); queue.Enqueue(10); int a = queue.Dequeue(); int b = queue.Dequeue(); Assert.AreEqual(a, 5); Assert.AreEqual(b, 10); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Assert.AreEqual(0, 1); } }
static Namespace GetNamespaceForType (CollectionType t) { switch (t) { case CollectionType.Int32: case CollectionType.Double: case CollectionType.Point: case CollectionType.Geometry: case CollectionType.Drawing: case CollectionType.PathFigure: case CollectionType.PathSegment: case CollectionType.GradientStop: case CollectionType.GeneralTransform: case CollectionType.Transform: case CollectionType.Vector: return Namespace.System_Windows_Media; case CollectionType.Timeline: case CollectionType.Clock: return Namespace.System_Windows_Media_Animation; default: throw new Exception (); } }
public void StackTest(CollectionType collectionType) { try { var stack = CollectionFactory.CreateAStack<int>(collectionType,10); stack.Push(5); stack.Push(10); int a = stack.Pop(); int b = stack.Pop(); Assert.AreEqual(a, 10); Assert.AreEqual(b, 5); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Assert.AreEqual(0, 1); } }
/// <summary> /// Initializes a new instance of the <see cref="ClrBooleanPropertyInfo"/> class. /// Constructor /// </summary> /// <param name="collection"> /// Wether the field is a collection /// </param> /// <param name="name"> /// Name of the field /// </param> /// <param name="description"> /// Description for the field, used for commenting /// </param> /// <param name="optional"> /// Whether the field is optionable \ nullable /// </param> /// <param name="isKey"> /// Whether the property is the primary key /// </param> /// <param name="alternativeDatabaseColumnName"> /// Name of the database column name, if it's different from the .NET property name. /// </param> public ClrBooleanPropertyInfo( CollectionType collection, string name, string description, bool optional, bool isKey, string alternativeDatabaseColumnName) : base(collection, name, description, optional, "bool", "Dhgms.DataManager.Model.SearchFilter.Boolean", "Boolean", false, "false", false, isKey, true, typeof(bool), alternativeDatabaseColumnName) { }
/// <summary> /// Initializes a new instance of the <see cref="ClrStringPropertyInfo"/> class. /// Constructor /// </summary> /// <param name="collection"> /// Wether the field is a collection /// </param> /// <param name="name"> /// Name of the field /// </param> /// <param name="description"> /// Description for the field, used for commenting /// </param> /// <param name="optional"> /// Whether the field is optionable \ nullable /// </param> /// <param name="isKey"> /// Whether the property is the primary key /// </param> /// <param name="alternativeDatabaseColumnName"> /// Name of the database column name, if it's different from the .NET property name. /// </param> public ClrGuidPropertyInfo( CollectionType collection, string name, string description, bool optional, bool isKey, string alternativeDatabaseColumnName) : base(collection, name, description, optional, "System.Guid", "Dhgms.DataManager.Model.SearchFilter.Guid", "Guid", false, "Guid.Empty", false, isKey, false, typeof(Guid), alternativeDatabaseColumnName) { }
protected string GetTypeString() { var sb = new StringBuilder(); if (CollectionType != CollectionType.None) { sb.Append($"{CollectionType.ToString()}<"); } sb.Append(Name); if (CollectionType != CollectionType.None) { sb.Append(">"); } if (IsOptional) { sb.Append("?"); } return(sb.ToString()); }
internal override object ProcessCollection(object collection, CollectionType type) { if (collection == CollectionType.UnfetchedCollection) { return(null); } if (collection != null) { IPersistentCollection coll; if (type.IsArrayType) { coll = Session.PersistenceContext.GetCollectionHolder(collection); } else { coll = (IPersistentCollection)collection; } Collections.ProcessReachableCollection(coll, type, owner, Session); } return(null); }
private string AddTable(string name, CollectionType collectionType, Type keyType, Type valueType) { using (var command = _connection.CreateCommand()) { command.CommandText = string.Format("INSERT INTO {0} (name, collectionType, tableName, keyType, valueType)" + "VALUES (@name, @collectionType, @tableName, @keyType, @valueType)", TableName); var keyTypeId = keyType != null ? (int?)_typeModel.GetTypeId(keyType) : null; var valueTypeId = _typeModel.GetTypeId(valueType); var tableName = CreateTableNameFor(name); command.Parameters.AddWithValue("@name", name); command.Parameters.AddWithValue("@collectionType", collectionType); command.Parameters.AddWithValue("@tableName", tableName); command.Parameters.AddWithValue("@keyType", keyTypeId); command.Parameters.AddWithValue("@valueType", valueTypeId); command.ExecuteNonQuery(); return(tableName); } }
private void NLSendNotifications(CollectionDataModel model) { // prevent for sending notification twice - for old and new loan to sane customer if (!sendNotificationForNewLoan) { model.SmsSendingAllowed = false; model.ImailSendingAllowed = false; model.EmailSendingAllowed = false; model.UpdateCustomerAllowed = false; } CollectionType collectionType = GetCollectionType(model.LateDays); CollectionStatusNames collectionStatusName = GetCollectionStatusName(collectionType); string emailTemplate = GetCollectionEmailTemplateName(collectionType); bool isSendEmail = IsSendEmail(collectionType); bool isSendSMS = IsSendSMS(collectionType); bool isSendImail = IsSendImail(collectionType); bool isChangeStatusCall = IsChangeStatusCall(collectionType); if (isChangeStatusCall) { ChangeStatus(model.CustomerID, 1, collectionStatusName, collectionType, model); } if (isSendEmail) { SendCollectionEmail(emailTemplate, model, collectionType); } if (isSendSMS) { SendCollectionSms(model, collectionType); } if (isSendImail) { SendCollectionImail(model, collectionType); } }
static void WriteToFile(CollectionType<Tor> collection) { System.IO.StreamWriter file = null; string FileName = "Lab 3.txt"; try { file = new System.IO.StreamWriter(FileName); foreach (var value in collection) file.WriteLine("\nВнутренний радиус- {0}\nID - {1}\nВнешний радиус - {2}\n", value.innerRadius, value.UniqueId, value.outerRadius); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (file != null) { file.Close(); } } }
public IEnumerable <Square> this[int position, CollectionType type] { get { if (position < 1 || position > Size) { throw new ArgumentOutOfRangeException("position", $"Position can only be between 1 and {Size}"); } var p = position - 1; if (type == CollectionType.Square) { var x = p / SquareSize * SquareSize; var y = p % SquareSize * SquareSize; for (var r = 0; r < SquareSize; r++) { for (var c = 0; c < SquareSize; c++) { yield return(Squares[y + c, x + r]); } } yield break; } for (var i = 0; i < Size; i++) { var col = type == CollectionType.Column ? p : i; var row = type == CollectionType.Column ? i : p; yield return(Squares[col, row]); } } }
public void Initialize( JsonSourceGenerationMode generationMode, string typeRef, string typeInfoPropertyName, Type type, ClassType classType, bool isValueType, JsonNumberHandling?numberHandling, List <PropertyGenerationSpec>?propertiesMetadata, CollectionType collectionType, TypeGenerationSpec?collectionKeyTypeMetadata, TypeGenerationSpec?collectionValueTypeMetadata, ObjectConstructionStrategy constructionStrategy, TypeGenerationSpec?nullableUnderlyingTypeMetadata, string?converterInstantiationLogic, bool implementsIJsonOnSerialized, bool implementsIJsonOnSerializing) { GenerationMode = generationMode; TypeRef = $"global::{typeRef}"; TypeInfoPropertyName = typeInfoPropertyName; Type = type; ClassType = classType; IsValueType = isValueType; CanBeNull = !isValueType || nullableUnderlyingTypeMetadata != null; NumberHandling = numberHandling; PropertiesMetadata = propertiesMetadata; CollectionType = collectionType; CollectionKeyTypeMetadata = collectionKeyTypeMetadata; CollectionValueTypeMetadata = collectionValueTypeMetadata; ConstructionStrategy = constructionStrategy; NullableUnderlyingTypeMetadata = nullableUnderlyingTypeMetadata; ConverterInstantiationLogic = converterInstantiationLogic; ImplementsIJsonOnSerialized = implementsIJsonOnSerialized; ImplementsIJsonOnSerializing = implementsIJsonOnSerializing; }
private CollectionStatusNames GetCollectionStatusName(CollectionType collectionType) { switch (collectionType) { case CollectionType.CollectionDay1to6: return(CollectionStatusNames.DaysMissed1To14); case CollectionType.CollectionDay15: return(CollectionStatusNames.DaysMissed15To30); case CollectionType.CollectionDay31: return(CollectionStatusNames.DaysMissed31To45); case CollectionType.CollectionDay46: return(CollectionStatusNames.DaysMissed46To60); case CollectionType.CollectionDay60: return(CollectionStatusNames.DaysMissed61To90); case CollectionType.CollectionDay90: return(CollectionStatusNames.DaysMissed90Plus); } return(CollectionStatusNames.Default); }
private string GetCollectionEmailTemplateName(CollectionType collectionType) { switch (collectionType) { case CollectionType.CollectionDay0: return(CollectionDay0EmailTemplate); case CollectionType.CollectionDay15: return(CollectionDay15EmailTemplate); case CollectionType.CollectionDay1to6: return(CollectionDay1to6EmailTemplate); case CollectionType.CollectionDay31: return(CollectionDay31EmailTemplate); case CollectionType.CollectionDay7: return(CollectionDay7EmailTemplate); case CollectionType.CollectionDay8to14: return(CollectionDay8to14EmailTemplate); } return(String.Empty); }
public override SqlFragment Visit(DbGroupByExpression expression) { // first process the input DbGroupExpressionBinding e = expression.Input; SelectStatement innerSelect = VisitInputExpressionEnsureSelect(e.Expression, e.VariableName, e.VariableType); SelectStatement select = WrapIfNotCompatible(innerSelect, expression.ExpressionKind); CollectionType ct = (CollectionType)expression.ResultType.EdmType; RowType rt = (RowType)ct.TypeUsage.EdmType; int propIndex = 0; foreach (DbExpression key in expression.Keys) { select.AddGroupBy(key.Accept(this)); propIndex++; } for (int agg = 0; agg < expression.Aggregates.Count; agg++) { DbAggregate a = expression.Aggregates[agg]; DbFunctionAggregate fa = a as DbFunctionAggregate; if (fa == null) { throw new NotSupportedException(); } string alias = rt.Properties[propIndex++].Name; ColumnFragment functionCol = new ColumnFragment(null, null); functionCol.Literal = HandleFunction(fa, a.Arguments[0].Accept(this)); functionCol.ColumnAlias = alias; select.Columns.Add(functionCol); } return(select); }
/// <summary> /// 将对应的类型数据添加到明细栏中 /// </summary> /// <param name="anesDetail">明细栏控件</param> /// <param name="anesEventTable">事件表数据</param> /// <param name="anesClassType">事件类型</param> /// <param name="collectionText">明细类型的信息:用药OR麻药OR事件</param> /// <param name="collectionType">对应个明细类型:事件OR用药OR汇总</param> /// <param name="collectionColor">明细栏控件的颜色</param> /// <param name="startDate">起始时间</param> /// <param name="filtItemName">事件类型EVENT_CLASS_CODE:B、C、2</param> /// <param name="drugShowType">用药明细显示类型:单点OR持续OR全部</param> /// <param name="isYouDao">当前系统是否为诱导系统,默认是麻醉系统</param> /// <param name="operationMaster">主表信息</param> private MedAnesSheetDetailCollection AddAnesSheetDetailCollection(MedAnesSheetDetails anesDetail, List <MED_ANESTHESIA_EVENT> anesEventTable, AnesClassType[] anesClasses, string collectionText, CollectionType collectionType, Color collectionColor, DateTime startDate, string filtItemName, AnesDrugShowType drugShowType, bool isYouDao, MED_OPERATION_MASTER operationMaster) { MedAnesSheetDetailCollection collection = this.GenDetailCollection(anesEventTable, anesClasses, collectionText, collectionType, startDate, filtItemName, drugShowType, isYouDao, operationMaster); if (collection != null) { collection.Color = collectionColor; anesDetail.Collections.Add(collection); } return(collection); }
static Namespace GetNamespaceForType(CollectionType t) { switch (t) { case CollectionType.Int32: case CollectionType.Double: case CollectionType.Point: case CollectionType.Geometry: case CollectionType.Drawing: case CollectionType.PathFigure: case CollectionType.PathSegment: case CollectionType.GradientStop: case CollectionType.GeneralTransform: case CollectionType.Transform: case CollectionType.Vector: return(Namespace.System_Windows_Media); case CollectionType.Timeline: case CollectionType.Clock: return(Namespace.System_Windows_Media_Animation); default: throw new Exception(); } }
// <summary> // Convert CSpace TypeMetadata into OSpace TypeMetadata // </summary> // <returns> OSpace type metadata </returns> private EdmType ConvertCSpaceToOSpaceType(EdmType cdmType) { EdmType clrType = null; if (Helper.IsCollectionType(cdmType)) { var elemType = ConvertCSpaceToOSpaceType(((CollectionType)cdmType).TypeUsage.EdmType); clrType = new CollectionType(elemType); } else if (Helper.IsRowType(cdmType)) { var clrProperties = new List <EdmProperty>(); var rowType = (RowType)cdmType; foreach (var column in rowType.Properties) { var clrPropertyType = ConvertCSpaceToOSpaceType(column.TypeUsage.EdmType); var clrProperty = new EdmProperty(column.Name, TypeUsage.Create(clrPropertyType)); clrProperties.Add(clrProperty); } clrType = new RowType(clrProperties, rowType.InitializerMetadata); } else if (Helper.IsRefType(cdmType)) { clrType = new RefType((EntityType)ConvertCSpaceToOSpaceType(((RefType)cdmType).ElementType)); } else if (Helper.IsPrimitiveType(cdmType)) { clrType = _objectCollection.GetMappedPrimitiveType(((PrimitiveType)cdmType).PrimitiveTypeKind); } else { clrType = ((ObjectTypeMapping)GetMap(cdmType)).ClrType; } Debug.Assert((null != clrType), "null converted clr type"); return(clrType); }
private ODataCollectionValue ReadCollection(ODataMessageReader messageReader) { Contract.Assert(messageReader != null); ODataCollectionReader reader = messageReader.CreateODataCollectionReader(CollectionType.ElementType()); ArrayList items = new ArrayList(); string typeName = null; while (reader.Read()) { if (ODataCollectionReaderState.Value == reader.State) { items.Add(reader.Item); } else if (ODataCollectionReaderState.CollectionStart == reader.State) { typeName = reader.Item.ToString(); } } return(new ODataCollectionValue { Items = items, TypeName = typeName }); }
public virtual void EvictCollection(object value, CollectionType type) { IPersistentCollection pc; if (type.IsArrayType) { pc = Session.PersistenceContext.RemoveCollectionHolder(value); } else if (value is IPersistentCollection) { pc = (IPersistentCollection)value; } else { return; //EARLY EXIT! } IPersistentCollection collection = pc; if (collection.UnsetSession(Session)) { EvictCollection(collection); } }
public CatalogTemplateSelector(CollectionType collectionType) { _collectionType = collectionType; }
private DbExpression RewriteCollection(DbExpression expression, CollectionType collectionType) { DbExpression target = expression; // If the collection expression is a project expression, get a strongly typed reference to it for later use. DbProjectExpression project = null; if (DbExpressionKind.Project == expression.ExpressionKind) { project = (DbProjectExpression)expression; target = project.Input.Expression; } // If Relationship span is enabled and the source of this collection is (directly or indirectly) // a RelationshipNavigation operation, it may be possible to optimize the relationship span rewrite // for the Entities produced by the navigation. NavigationInfo navInfo = null; if (this.RelationshipSpan) { // Attempt to find a RelationshipNavigationExpression in the collection-defining expression target = RelationshipNavigationVisitor.FindNavigationExpression(target, _aliasGenerator, out navInfo); } // If a relationship navigation expression defines this collection, make the Ref that is the navigation source // and the source association end available for possible use when the projection over the collection is rewritten. if (navInfo != null) { this.EnterNavigationCollection(navInfo); } else { // Otherwise, add a null navigation info instance to the stack to indicate that relationship navigation // cannot be optimized for the entities produced by this collection expression (if it is a collection of entities). this.EnterCollection(); } // If the expression is already a DbProjectExpression then simply visit the projection, // instead of introducing another projection over the existing one. DbExpression result = expression; if (project != null) { DbExpression newProjection = this.Rewrite(project.Projection); if (!object.ReferenceEquals(project.Projection, newProjection)) { result = target.BindAs(project.Input.VariableName).Project(newProjection); } } else { // This is not a recognized special case, so simply add the span projection over the original // collection-producing expression, if it is required. DbExpressionBinding collectionBinding = target.BindAs(_aliasGenerator.Next()); DbExpression projection = collectionBinding.Variable; DbExpression spannedProjection = this.Rewrite(projection); if (!object.ReferenceEquals(projection, spannedProjection)) { result = collectionBinding.Project(spannedProjection); } } // Remove any navigation information from scope, if it was added this.ExitCollection(); // If a navigation expression defines this collection and its navigation information was used to // short-circuit relationship span rewrites, then enclose the entire rewritten expression in a // Lambda binding that brings the source Ref of the navigation operation into scope. This ref is // refered to by VariableReferenceExpressions in the original navigation expression as well as any // short-circuited relationship span columns in the rewritten expression. if (navInfo != null && navInfo.InUse) { // Create a Lambda function that binds the original navigation source expression under the variable name // used in the navigation expression and the relationship span columns, and which has its Lambda body // defined by the rewritten collection expression. List <DbVariableReferenceExpression> formals = new List <DbVariableReferenceExpression>(1); formals.Add(navInfo.SourceVariable); List <DbExpression> args = new List <DbExpression>(1); args.Add(navInfo.Source); result = DbExpressionBuilder.Invoke(DbExpressionBuilder.Lambda(result, formals), args); } // Return the (possibly rewritten) collection expression. return(result); }
/// <summary> Cascade an action to a collection</summary> private async Task CascadeCollectionAsync(object parent, object child, CascadeStyle style, object anything, CollectionType type, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ICollectionPersister persister = eventSource.Factory.GetCollectionPersister(type.Role); IType elemType = persister.ElementType; CascadePoint oldCascadeTo = point; if (point == CascadePoint.AfterInsertBeforeDelete) { point = CascadePoint.AfterInsertBeforeDeleteViaCollection; } //cascade to current collection elements if (elemType.IsEntityType || elemType.IsAnyType || elemType.IsComponentType) { await(CascadeCollectionElementsAsync(parent, child, type, style, elemType, anything, persister.CascadeDeleteEnabled, cancellationToken)).ConfigureAwait(false); } point = oldCascadeTo; }
/// <summary> Cascade to the collection elements</summary> private async Task CascadeCollectionElementsAsync(object parent, object child, CollectionType collectionType, CascadeStyle style, IType elemType, object anything, bool isCascadeDeleteEnabled, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); bool reallyDoCascade = style.ReallyDoCascade(action) && child != CollectionType.UnfetchedCollection; if (reallyDoCascade) { log.Info("cascade " + action + " for collection: " + collectionType.Role); foreach (object o in action.GetCascadableChildrenIterator(eventSource, collectionType, child)) { await(CascadePropertyAsync(parent, o, elemType, style, null, anything, isCascadeDeleteEnabled, cancellationToken)).ConfigureAwait(false); } log.Info("done cascade " + action + " for collection: " + collectionType.Role); } var childAsPersColl = child as IPersistentCollection; bool deleteOrphans = style.HasOrphanDelete && action.DeleteOrphans && elemType.IsEntityType && childAsPersColl != null; //a newly instantiated collection can't have orphans if (deleteOrphans) { // handle orphaned entities!! log.Info("deleting orphans for collection: " + collectionType.Role); // we can do the cast since orphan-delete does not apply to: // 1. newly instantiated collections // 2. arrays (we can't track orphans for detached arrays) string entityName = collectionType.GetAssociatedEntityName(eventSource.Factory); await(DeleteOrphansAsync(entityName, childAsPersColl, cancellationToken)).ConfigureAwait(false); log.Info("done deleting orphans for collection: " + collectionType.Role); } }
/// <summary> /// If the collection has existed, reset the collection. /// - collectionType = STANDARD: the collection is reset to STANDARD /// - collectionType = PARTITIONED: the collection is reset to PARTITIONED /// - collectionType = UNDEFINED: the collection's partition property remains the same as original one /// If the collection does not exist, create the collection /// - collectionType = STANDARD: the newly created collection is STANDARD /// - collectionType = PARTITIONED: the newly created collection is PARTITIONED /// - collectionType = UNDEFINED: an exception is thrown! /// </summary> public void ResetCollection(CollectionType collectionType = CollectionType.STANDARD, int?edgeSpillThreshold = 1) { EnsureDatabaseExist(); DocumentCollection docDBCollection = this.DocDBClient.CreateDocumentCollectionQuery(this._docDBDatabaseUri) .Where(c => c.Id == this.DocDBCollectionId) .AsEnumerable() .FirstOrDefault(); // Delete the collection if it exists if (docDBCollection != null) { DeleteCollection(); } switch (collectionType) { case CollectionType.STANDARD: case CollectionType.PARTITIONED: break; case CollectionType.UNDEFINED: if (this.CollectionType == CollectionType.UNDEFINED) { throw new Exception("Can't specify CollectionType.UNDEFINED to reset a non-existing collection"); } collectionType = this.CollectionType; break; default: throw new ArgumentOutOfRangeException(nameof(collectionType), collectionType, null); } Debug.Assert(collectionType != CollectionType.UNDEFINED); CreateCollection(collectionType == CollectionType.PARTITIONED); this.CollectionType = collectionType; // // Create a meta-data document! // Here we just store the "edgeSpillThreshold" in it // JValue jEdgeSpillThreshold; if (edgeSpillThreshold == null || edgeSpillThreshold <= 0) { jEdgeSpillThreshold = (JValue)0; this.EdgeSpillThreshold = 0; } else // edgeSpillThreshold > 0 { jEdgeSpillThreshold = (JValue)edgeSpillThreshold; this.EdgeSpillThreshold = (int)edgeSpillThreshold; } JObject metaObject = new JObject { [KW_DOC_ID] = "metadata", [KW_DOC_PARTITION] = "metapartition", ["_edgeSpillThreshold"] = jEdgeSpillThreshold }; CreateDocumentAsync(metaObject).Wait(); // // Upload stored procedure `BulkOperation` // StoredProcedure storedProcedure = new StoredProcedure() { Id = "BulkOperation", Body = GraphView.Properties.Resources.BulkOperation, }; this.DocDBClient.CreateStoredProcedureAsync( this._docDBCollectionUri, storedProcedure, null ).Wait(); Trace.WriteLine($"[ResetCollection] Database/Collection {this.DocDBDatabaseId}/{this.DocDBCollectionId} has been reset."); }
private void DereferenceCollection(CollectionType collectionType, bool implicitJoin, bool indexed, string classAlias) { _dereferenceType = DerefCollection; string role = collectionType.Role; //foo.bars.size (also handles deprecated stuff like foo.bars.maxelement for backwardness) IASTNode sibling = NextSibling; bool isSizeProperty = sibling != null && CollectionProperties.IsAnyCollectionProperty(sibling.Text); if (isSizeProperty) { indexed = true; //yuck!} } IQueryableCollection queryableCollection = SessionFactoryHelper.RequireQueryableCollection(role); string propName = Path; FromClause currentFromClause = Walker.CurrentFromClause; if (Walker.StatementType != HqlSqlWalker.SELECT && indexed && classAlias == null) { // should indicate that we are processing an INSERT/UPDATE/DELETE // query with a subquery implied via a collection property // function. Here, we need to use the table name itself as the // qualification alias. // TODO : verify this works for all databases... // TODO : is this also the case in non-"indexed" scenarios? string alias = GetLhs().FromElement.Queryable.TableName; _columns = FromElement.ToColumns(alias, _propertyPath, false, true); } //We do not look for an existing join on the same path, because //it makes sense to join twice on the same collection role FromElementFactory factory = new FromElementFactory( currentFromClause, GetLhs().FromElement, propName, classAlias, GetColumns(), implicitJoin ); FromElement elem = factory.CreateCollection(queryableCollection, role, _joinType, _fetch, indexed); if (Log.IsDebugEnabled) { Log.Debug("dereferenceCollection() : Created new FROM element for " + propName + " : " + elem); } SetImpliedJoin(elem); FromElement = elem; // This 'dot' expression now refers to the resulting from element. if (isSizeProperty) { elem.Text = ""; elem.UseWhereFragment = false; } if (!implicitJoin) { IEntityPersister entityPersister = elem.EntityPersister; if (entityPersister != null) { Walker.AddQuerySpaces(entityPersister.QuerySpaces); } } Walker.AddQuerySpaces(queryableCollection.CollectionSpaces); // Always add the collection's query spaces. }
/// <summary> /// Iterate just the elements of the collection that are already there. Don't load /// any new elements from the database. /// </summary> public static IEnumerable GetLoadedElementsIterator(ISessionImplementor session, CollectionType collectionType, object collection) { if (CollectionIsInitialized(collection)) { // handles arrays and newly instantiated collections return(collectionType.GetElementsIterator(collection, session)); } else { // does not handle arrays (that's ok, cos they can't be lazy) // or newly instantiated collections, so we can do the cast return(((IPersistentCollection)collection).QueuedAdditionIterator); } }
/// <summary> /// Initializes a new connection to DocDB. /// Contains four string: Url, Key, Database's ID, Collection's ID /// </summary> /// <param name="docDBEndpointUrl">The Url</param> /// <param name="docDBAuthorizationKey">The Key</param> /// <param name="docDBDatabaseID">Database's ID</param> /// <param name="docDBCollectionID">Collection's ID</param> public GraphViewConnection( string docDBEndpointUrl, string docDBAuthorizationKey, string docDBDatabaseID, string docDBCollectionID, bool useReverseEdges = true, CollectionType collectionType = CollectionType.UNDEFINED, string preferredLocation = null) { // TODO: Parameter checking! // Initialze the two URI for future use // They are immutable during the life of this connection this._docDBDatabaseUri = UriFactory.CreateDatabaseUri(docDBDatabaseID); this._docDBCollectionUri = UriFactory.CreateDocumentCollectionUri(docDBDatabaseID, docDBCollectionID); this.DocDBUrl = docDBEndpointUrl; this.DocDBPrimaryKey = docDBAuthorizationKey; this.DocDBDatabaseId = docDBDatabaseID; this.DocDBCollectionId = docDBCollectionID; this.UseReverseEdges = useReverseEdges; this.Identifier = $"{docDBEndpointUrl}\0{docDBDatabaseID}\0{docDBCollectionID}"; this.VertexCache = new VertexObjectCache(this); this.Bulk = new Bulk(this); ConnectionPolicy connectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp, }; if (!string.IsNullOrEmpty(preferredLocation)) { connectionPolicy.PreferredLocations.Add(preferredLocation); } this.DocDBClient = new DocumentClient(new Uri(this.DocDBUrl), this.DocDBPrimaryKey, connectionPolicy); this.DocDBClient.OpenAsync().Wait(); // // Check whether it is a partition collection (if exists) // DocumentCollection docDBCollection; try { docDBCollection = this.DocDBClient.CreateDocumentCollectionQuery( UriFactory.CreateDatabaseUri(this.DocDBDatabaseId)) .Where(c => c.Id == this.DocDBCollectionId) .AsEnumerable() .FirstOrDefault(); } catch (AggregateException aggex) when((aggex.InnerException as DocumentClientException)?.Error.Code == "NotFound") { // Now the database does not exist! // NOTE: If the database exists, but the collection does not exist, it won't be an exception docDBCollection = null; } bool?isPartitionedNow = (docDBCollection?.PartitionKey.Paths.Count > 0); if (isPartitionedNow.HasValue && isPartitionedNow.Value) { if (collectionType == CollectionType.STANDARD) { throw new Exception("Can't specify CollectionType.STANDARD on an existing partitioned collection"); } } else if (isPartitionedNow.HasValue && !isPartitionedNow.Value) { if (collectionType == CollectionType.PARTITIONED) { throw new Exception("Can't specify CollectionType.PARTITIONED on an existing standard collection"); } } this.CollectionType = collectionType; if (collectionType == CollectionType.UNDEFINED) { if (docDBCollection == null) { // Do nothing } else if (docDBCollection.PartitionKey != null && docDBCollection.PartitionKey.Paths.Count < 1) { this.CollectionType = CollectionType.STANDARD; } else if (docDBCollection.PartitionKey != null && docDBCollection.PartitionKey.Paths.Count > 0 && docDBCollection.PartitionKey.Paths[0].Equals($"/{KW_DOC_PARTITION}", StringComparison.OrdinalIgnoreCase)) { this.CollectionType = CollectionType.PARTITIONED; } else { throw new Exception(string.Format("Collection not properly configured. If you wish to configure a partitioned collection, please chose /{0} as partitionKey", KW_DOC_PARTITION)); } } // Retrieve metadata from DocDB JObject metaObject = RetrieveDocumentById("metadata"); if (metaObject != null) { Debug.Assert((int?)metaObject["_edgeSpillThreshold"] != null); this.EdgeSpillThreshold = (int)metaObject["_edgeSpillThreshold"]; } Debug.Assert(this.EdgeSpillThreshold >= 0, "The edge-spill threshold should >= 0"); }
public override IEnumerable GetCascadableChildrenIterator(IEventSource session, CollectionType collectionType, object collection) { // replicate does cascade to uninitialized collections return(GetLoadedElementsIterator(session, collectionType, collection)); }
/// <summary> /// Given a collection, get an iterator of all its children, loading them /// from the database if necessary. /// </summary> /// <param name="session">The session within which the cascade is occurring. </param> /// <param name="collectionType">The mapping type of the collection. </param> /// <param name="collection">The collection instance. </param> /// <returns> The children iterator. </returns> private static IEnumerable GetAllElementsIterator(IEventSource session, CollectionType collectionType, object collection) { return(collectionType.GetElementsIterator(collection, session)); }
/// <summary> /// Given a collection, get an iterator of the children upon which the /// current cascading action should be visited. /// </summary> /// <param name="session">The session within which the cascade is occurring. </param> /// <param name="collectionType">The mapping type of the collection. </param> /// <param name="collection">The collection instance. </param> /// <returns> The children iterator. </returns> public abstract IEnumerable GetCascadableChildrenIterator(IEventSource session, CollectionType collectionType, object collection);
public override IEnumerable GetCascadableChildrenIterator(IEventSource session, CollectionType collectionType, object collection) { // merges don't cascade to uninitialized collections //TODO: perhaps this does need to cascade after all.... return(GetLoadedElementsIterator(session, collectionType, collection)); }
public ElementCollection(CollectionType collectionType, int minimum, int maximum) : this(collectionType) { this.minimum = minimum; this.maximum = maximum; }
public ElementCollection(CollectionType collectionType) { this.collectionType = collectionType; this.items = new ArrayList(); }
/// <summary>Implements the visitor pattern for the type.</summary> /// <returns>The implemented visitor pattern.</returns> /// <param name="type">The type.</param> protected override EdmType VisitType(EdmType type) { var retType = type; if (BuiltInTypeKind.RefType == type.BuiltInTypeKind) { var refType = (RefType)type; var mappedEntityType = (EntityType)VisitType(refType.ElementType); if (!ReferenceEquals(refType.ElementType, mappedEntityType)) { retType = new RefType(mappedEntityType); } } else if (BuiltInTypeKind.CollectionType == type.BuiltInTypeKind) { var collectionType = (CollectionType)type; var mappedElementType = VisitTypeUsage(collectionType.TypeUsage); if (!ReferenceEquals(collectionType.TypeUsage, mappedElementType)) { retType = new CollectionType(mappedElementType); } } else if (BuiltInTypeKind.RowType == type.BuiltInTypeKind) { var rowType = (RowType)type; List <KeyValuePair <string, TypeUsage> > mappedPropInfo = null; for (var idx = 0; idx < rowType.Properties.Count; idx++) { var originalProp = rowType.Properties[idx]; var mappedPropType = VisitTypeUsage(originalProp.TypeUsage); if (!ReferenceEquals(originalProp.TypeUsage, mappedPropType)) { if (mappedPropInfo == null) { mappedPropInfo = new List <KeyValuePair <string, TypeUsage> >( rowType.Properties.Select( prop => new KeyValuePair <string, TypeUsage>(prop.Name, prop.TypeUsage) )); } mappedPropInfo[idx] = new KeyValuePair <string, TypeUsage>(originalProp.Name, mappedPropType); } } if (mappedPropInfo != null) { var mappedProps = mappedPropInfo.Select(propInfo => new EdmProperty(propInfo.Key, propInfo.Value)); retType = new RowType(mappedProps, rowType.InitializerMetadata); } } else { if (!_metadata.TryGetType(type.Name, type.NamespaceName, type.DataSpace, out retType) || null == retType) { throw new ArgumentException(Strings.Cqt_Copier_TypeNotFound(TypeHelpers.GetFullName(type.NamespaceName, type.Name))); } } return(retType); }
internal GameCollection GetCollection(CollectionType t) { switch (t) { case CollectionType.Aircraft: return _aircraftTypes; case CollectionType.Building: return _buildingTypes; case CollectionType.Infantry: return _infantryTypes; case CollectionType.Overlay: return _overlayTypes; case CollectionType.Smudge: return _smudgeTypes; case CollectionType.Terrain: return _terrainTypes; case CollectionType.Vehicle: return _vehicleTypes; case CollectionType.Tiles: return _tileTypes; default: throw new ArgumentOutOfRangeException("t"); } }
public override IEnumerable GetCascadableChildrenIterator(IEventSource session, CollectionType collectionType, object collection) { // persists don't cascade to uninitialized collections return(GetAllElementsIterator(session, collectionType, collection)); }