// This is the builder function that gets passed to the core IAsyncCollector binders. public IAsyncCollector <TMessage> BuildFromAttribute(TAttribute attribute) { var obj = this.Builder(attribute, typeof(TMessage)); var collector = (IAsyncCollector <TMessage>)obj; return(collector); }
protected override Task <IValueProvider> BuildAsync( TAttribute attrResolved, ValueBindingContext context) { string invokeString = Cloner.GetInvokeString(attrResolved); object obj = _buildFromAttribute(attrResolved); IAsyncCollector <TMessage> collector; if (_converter != null) { // Apply a converter var innerCollector = (IAsyncCollector <TType>)obj; collector = new TypedAsyncCollectorAdapter <TMessage, TType, TAttribute>( innerCollector, _converter, attrResolved, context); } else { collector = (IAsyncCollector <TMessage>)obj; } var vp = CoerceValueProvider(_mode, invokeString, collector); return(Task.FromResult(vp)); }
public static IEnumerable <Tuple <Type, TAttribute> > EnumTypesWithAttribute <TAttribute>() where TAttribute : Attribute { List <Tuple <Type, Attribute> > cachedTypes; if (m_TypeByAttributeCache.TryGetValue(typeof(TAttribute), out cachedTypes)) { foreach (Tuple <Type, Attribute> tuple in cachedTypes) { yield return(Tuple.Create(tuple.Item1, (TAttribute)tuple.Item2)); } yield break; } cachedTypes = new List <Tuple <Type, Attribute> >(); var assemblies = (Assembly[])typeof(Editor).Assembly.GetTypes().Where(t => t.Name == "EditorAssemblies").FirstOrDefault() .GetProperty("loadedAssemblies", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null, null); foreach (Type t in GetTypes()) { TAttribute attr = t.GetAttribute <TAttribute>(); if (attr != null) { cachedTypes.Add(Tuple.Create(t, (Attribute)attr)); yield return(Tuple.Create(t, attr)); } } m_TypeByAttributeCache.Add(typeof(TAttribute), cachedTypes); }
public void Init() { serviceClient = new UserServiceClient(); // create test users that can be used with the create and update methods User_in.Alias = alias; User_in.Password = "******"; User_in.Name = "Klaus Klaussen"; User_in.EMail = "*****@*****.**"; User_in.DeleteConfirmation = false; User_in.DeleteConfirmationSpecified = true; User_update.DeleteConfirmation = true; User_update.DeleteConfirmationSpecified = true; TAddress bill = new TAddress(); bill.FirstName = "Klaus"; bill.LastName = "Klaussen"; bill.Street = "Musterstraße 2"; bill.EMail = "*****@*****.**"; bill.Birthday = new DateTime(1976, 9, 25, 11, 33, 0); User_in.BillingAddress = bill; User_in.ShippingAddress = bill; TAttribute attr = new TAttribute(); attr.Name = "ChallengePhrase"; attr.Value = "my challenge phrase"; User_in.Attributes = new TAttribute[] { attr }; User_update.Path = path + alias; User_update.Password = "******"; User_update.Name = "Hans Hanssen"; User_update.EMail = "*****@*****.**"; // IMPORTANT!!! // .NET has the terrible behavior, to set all boolean and numeric value that are not // defined to "false" resp. "0" // So if you update an object and do not set the "IsVisible" flag, it will set the object to // invisible!!! User_update.DeleteConfirmation = true; TAddress bill_update = new TAddress(); bill_update.FirstName = "Hans"; bill_update.LastName = "Hanssen"; bill_update.Street = "Musterstraße 2b"; bill_update.Birthday = new DateTime(1976, 9, 25, 11, 33, 0); User_update.BillingAddress = bill_update; TAttribute attr_update = new TAttribute(); attr_update.Name = "ChallengePhrase"; attr_update.Value = "my updated challenge phrase"; User_update.Attributes = new TAttribute[] { attr_update }; }
public static TAttribute GetCustomAttributeOnType <TClass, TAttribute>() where TClass : class where TAttribute : Attribute { IEnumerable <TAttribute> attributes = AttributeHandler.GetCustomAttributesOnType <TClass, TAttribute>(); TAttribute attribute = attributes.FirstOrDefault(); return(attribute); }
public static TAttribute GetCustomAttributeOnType <TEnum, TAttribute>() where TEnum : struct, IConvertible where TAttribute : Attribute { IEnumerable <TAttribute> attributes = EnumHandler.GetCustomAttributesOnType <TEnum, TAttribute>(); TAttribute attribute = attributes.FirstOrDefault(); return(attribute); }
public void Init() { serviceClient = new CatalogServiceClient(); full = path + "/" + alias; // create test Catalogs that can be used with the create and update methods Catalog_in.Alias = alias; Catalog_in.IsVisible = true; Catalog_in.IsVisibleSpecified = true; Catalog_in.ParentCatalog = path; TLocalizedValue name_de = new TLocalizedValue(); name_de.LanguageCode = "de"; name_de.Value = "Mein Katalogname"; TLocalizedValue name_en = new TLocalizedValue(); name_en.LanguageCode = "en"; name_en.Value = "My Catalog Name"; Catalog_in.Name = new TLocalizedValue[] { name_de, name_en }; TAttribute attr = new TAttribute(); attr.Name = "Date"; attr.Type = "DateTime"; attr.Value = "2005-12-24T10:00:00"; Catalog_in.Attributes = new TAttribute[] { attr }; Catalog_update.Path = full; // IMPORTANT!!! // .NET has the terrible behavior, to set all boolean and numeric value that are not // defined to "false" resp. "0" // So if you update an object and do not set the "IsVisible" flag, it will set the object to // invisible!!! Catalog_update.IsVisible = true; Catalog_update.IsVisibleSpecified = true; TLocalizedValue name_de_updated = new TLocalizedValue(); name_de_updated.LanguageCode = "de"; name_de_updated.Value = "Mein geänderter Katalogname"; TLocalizedValue name_en_updated = new TLocalizedValue(); name_en_updated.LanguageCode = "en"; name_en_updated.Value = "My updated Catalog Name"; Catalog_update.Name = new TLocalizedValue[] { name_de_updated, name_en_updated }; TAttribute attr_update = new TAttribute(); attr_update.Name = "Date"; attr_update.Type = "DateTime"; attr_update.Value = "2005-12-24T18:00:00"; Catalog_update.Attributes = new TAttribute[] { attr_update }; }
public WrappedAttribute(TAttribute attribute) { InternalOrder = ++_currentIndex; Attribute = attribute; foreach (var associatedAttribute in Attribute.AssociatedAttributes .Where(associatedAttribute => associatedAttribute is TAttribute)) { AssociatedAttributes.Add(new WrappedAttribute((TAttribute)associatedAttribute)); } }
public EventTriggerBinding(JobHostConfiguration config, ParameterInfo parameter, TAttribute attribute, TraceWriter trace, EventTriggerAttributeBindingProvider <TAttribute> parent) { _config = config; _parameter = parameter; _attribute = attribute; _trace = trace; BindingDataContract = CreateBindingDataContract(); _parent = parent; }
public GenericTriggerbinding( ParameterInfo parameter, TAttribute attribute, TraceWriter trace, GenericFileTriggerBindingProvider <TAttribute, TFile> parent) { this._parameter = parameter; this._attribute = attribute; this._parent = parent; this._trace = trace; _bindingDataProvider = BindingDataProvider.FromTemplate(_attribute.Path); _bindingContract = CreateBindingContract(); }
private static TAttribute Map(this T_ATTRIBUTE model) { var attribute = new TAttribute { DifferentialPath = model.differential_path, ReferenceModelAttributeName = model.rm_attribute_name }; foreach (var child in model.children) { attribute.Children.Add(child.Map()); } return(attribute); }
/// <summary> /// 获取自定义Attribute /// </summary> /// <typeparam name="TModel">泛型</typeparam> /// <typeparam name="TAttribute">泛型</typeparam> /// <returns>未获取到则返回NULL</returns> /// 时间:2016-01-12 15:22 /// 备注: public static TAttribute GetCustom <TModel, TAttribute>() where TModel : class where TAttribute : Attribute { Type type = typeof(TModel); object[] cAttribute = type.GetCustomAttributes(typeof(TAttribute), true); if (cAttribute != null && cAttribute.Length > 0) { TAttribute tAttribute = cAttribute[0] as TAttribute; return(tAttribute); } return(null); }
private IEnumerable <PropertyWrapper <TAttribute> > GetProperties <TAttribute>() where TAttribute : Attribute { var properties = new List <PropertyWrapper <TAttribute> >(); foreach (PropertyInfo property in typeof(TEntity).GetProperties()) { TAttribute attribute = property.GetCustomAttribute <TAttribute>(); if (attribute != null) { properties.Add( new PropertyWrapper <TAttribute>(property, attribute)); } } return(properties); }
public void Init() { serviceClient = new CustomerServiceClient(); // create test customers that can be used with the create and update methods customer_in.Alias = alias; TAddress bill = new TAddress(); bill.FirstName = "Klaus"; bill.LastName = "Klaussen"; bill.Street = "Musterstraße 2"; bill.EMail = "*****@*****.**"; bill.Birthday = new DateTime(1976, 9, 25, 11, 33, 0, DateTimeKind.Local); bill.BirthdaySpecified = true; bill.VerifiedOn = new DateTime(2005, 1, 1); bill.VerifiedOnSpecified = true; customer_in.BillingAddress = bill; TAttribute attr = new TAttribute(); attr.Name = "Comment"; attr.Value = "my customer comment"; customer_in.Attributes = new TAttribute[] { attr }; customer_in.IsDoOrderAllowed = true; customer_in.IsDoOrderAllowedSpecified = true; customer_update.Path = path + alias; TAddress bill_update = new TAddress(); bill_update.FirstName = "Hans"; bill_update.LastName = "Hanssen"; bill_update.Street = "Musterstraße 2b"; bill_update.Birthday = new DateTime(1976, 9, 25, 11, 33, 0, DateTimeKind.Local); bill_update.BirthdaySpecified = true; bill_update.VerifiedOn = new DateTime(2005, 1, 1); bill_update.VerifiedOnSpecified = true; customer_update.BillingAddress = bill_update; TAttribute attr_update = new TAttribute(); attr_update.Name = "Comment"; attr_update.Value = "my updated customer comment"; customer_update.Attributes = new TAttribute[] { attr_update }; customer_update.IsDoOrderAllowed = true; customer_update.IsDoOrderAllowedSpecified = true; }
/// <summary> /// сохранить данные документа из формы в базу /// </summary> public void FillSaveDocument(Control panAttrs) { if (!IsValid) { return; } using (var db = new TDMSDataContext()) { // находим var doc = (from d in db.TDocuments where d.ID == int.Parse(Request["ID"]) select d).Single(); // сохраняем все введенные пользователем данные foreach (Control control in panAttrs.Controls) { if (control is ITextControl && control.ID != null && control.ID.StartsWith("txt")) { // проверяем существует ли такой атрибут у этого документа var attr = (from a in doc.TAttributes where a.Attribute == control.ID select a).SingleOrDefault(); // если не нашли то создаем и добавляем в базу if (attr == null) { attr = new TAttribute(); attr.Attribute = control.ID; doc.TAttributes.Add(attr); } // записываем новое значение attr.Value = ((ITextControl)control).Text; } } // изменяем статус документа doc.StatusID = TDocumentStatus.CREATED; db.SubmitChanges(); } Redirect(); }
/// <summary> /// Gets a collection of attributes from all enumerator values. /// </summary> /// <typeparam name="TEnum">The type of the enumerator.</typeparam> /// <typeparam name="TAttribute">The type of attribute to retrieve.</typeparam> /// <returns>A <see cref="List{TAttribute}"/> containing the resulting attribute list.</returns> public static List <TAttribute> GetEnumeratorAttributes <TEnum, TAttribute>() where TAttribute : Attribute { List <TAttribute> values = new List <TAttribute>(); MemberInfo[] members = typeof(TEnum).GetFields(BindingFlags.Public | BindingFlags.Static); foreach (MemberInfo member in members) { TAttribute attribute = Attribute.GetCustomAttribute(member, typeof(TAttribute)) as TAttribute; if (attribute != null && !values.Contains(attribute)) { values.Add(attribute); } } return(values); }
public static TAttribute GetEntityAttribute <T, TAttribute>() where TAttribute : Attribute { var type = typeof(T); string typeName = type.FullName; if (EntityAttrDict.ContainsKey(typeName)) { return((TAttribute)EntityAttrDict[typeName]); } TAttribute attr = type.GetCustomAttribute <TAttribute>(); if (attr != null) { EntityAttrDict[typeName] = attr; } return(attr); }
/// <summary> /// Looks for attribute by it's type in the call stack /// </summary> /// <typeparam name="TAttribute">Type of target attribute</typeparam> /// <returns>Returns attribute instance or null if not found</returns> public static TAttribute GetAttributeInCallStack <TAttribute>() { var stackTrace = new StackTrace(); TAttribute attribute = default(TAttribute); for (var i = 1; i < stackTrace.FrameCount; i++) { var frame = new StackFrame(i); object attributeObject = frame.GetMethod().GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(TAttribute)); if (attributeObject != null) { attribute = (TAttribute)attributeObject; break; } } return(attribute); }
public GenericTriggerbinding( JobHostConfiguration config, ParameterInfo parameter, TAttribute attribute, TraceWriter trace, GenericFileTriggerBindingProvider <TAttribute, TFile> parent) { this._config = config; this._parameter = parameter; this._attribute = attribute; this._parent = parent; this._trace = trace; MethodInfo methodInfo = (MethodInfo)parameter.Member; _functionName = methodInfo.Name; _bindingDataProvider = BindingDataProvider.FromTemplate(_attribute.Path.TrimStart('/'), ignoreCase: true); _bindingContract = CreateBindingContract(); }
public virtual IAttributeBinding <TProp, TAttribute> ToAttribute <TAttribute>(params object[] ctorArguments) where TAttribute : IPropertyAttribute { TAttribute attribute = (TAttribute)resolver.ResolveInstance <TAttribute>(ctorArguments); //Should we really allow ctor args? This is meant for Domain models that don't have any, but it also removes flexibility to not allow them Type mappingType; Type temp; Type propType = typeof(TProp); //REQUIREMENT: Multi value must be either ICollection<T> or T[] where T is the type for the mapping if (resolver.ReflectionHelper.IsArray(propType, out temp)) { mappingType = temp; } else if (resolver.ReflectionHelper.IsGenericCollection(propType, out temp)) { mappingType = temp; } else { mappingType = propType; } ////old: Multi-values must implement ICollection<>, not just IEnumerable<> (this lets us use the Add method) //if (typeof(TProp).IsAssignableFrom(typeof(ICollection<>))) //watch out for performance here, do this ONCE // mappingType = typeof(TProp).GetGenericArguments()[0]; //else // mappingType = typeof(TProp); Action <IPropertyAttribute, IBindingContainer> deferredMapping = (IPropertyAttribute attr, IBindingContainer container) => attr.ComplexTypeMapping = container.GetMapping(mappingType); IPropertyMapping propMapping = new PropertyMapping(propInfo, attribute, deferredMapping); var mapping = GetMapping(); if (mapping != null) { mapping.Add(propMapping); } return(new AttributeBinding <TProp, TAttribute>(propMapping, attribute)); }
protected override Task <IValueProvider> BuildAsync( TAttribute attrResolved, ValueBindingContext context) { string invokeString = Cloner.GetInvokeString(attrResolved); object obj = _buildFromAttribute(attrResolved); TUserType finalObj; if (_converter == null) { finalObj = (TUserType)obj; } else { var intermediateObj = (TType)obj; finalObj = _converter(intermediateObj, attrResolved, context); } IValueProvider vp = new ConstantValueProvider(finalObj, typeof(TUserType), invokeString); return(Task.FromResult(vp)); }
public void Init() { // initialize orderService orderService = new OrderService(); orderService.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); orderService.PreAuthenticate = true; orderService.Url = WEBSERVICE_URL; // initialize addresses TAddressNamed Address_in = new TAddressNamed(); Address_in.EMail = "*****@*****.**"; Address_in.FirstName = "Klaus"; Address_in.LastName = "Klaussen"; Address_in.Street = "Musterstraße 2"; Address_in.Street2 = "Ortsteil Niederfingeln"; TAttribute jobTitle = new TAttribute(); jobTitle.Name = "JobTitle"; jobTitle.Value = "best Job"; TAttribute salutation = new TAttribute(); salutation.Name = "Salutation"; salutation.Value = "Dr."; Address_in.Attributes = new TAttribute[] { jobTitle, salutation }; TAddressNamed Address_up = new TAddressNamed(); Address_up.FirstName = "Hans"; Address_up.LastName = "Hanssen"; Address_up.Street = "Musterstraße 2b"; Address_up.Street2 = "Ortsteil Oberfingeln"; //initialize order input data Order_in.Alias = alias; Order_in.Customer = customer; Order_in.BillingAddress = Address_in; Order_in.CreationDate = new DateTime(2006, 1, 1, 12, 0, 0, DateTimeKind.Local); Order_in.ViewedOn = new DateTime(2006, 1, 1, 23, 59, 0, DateTimeKind.Local); Order_in.ViewedOnSpecified = true; TAttribute OrderAttr_in = new TAttribute(); OrderAttr_in.Name = "Comment"; OrderAttr_in.Value = "my order comment"; Order_in.Attributes = new TAttribute[] { OrderAttr_in }; TProductLineItemIn Product_in = new TProductLineItemIn(); Product_in.Product = "/Shops/DemoShop/Products/ho_1112105010"; Product_in.Quantity = 10; TLineItemContainerIn lineItemContainer = new TLineItemContainerIn(); lineItemContainer.CurrencyID = "EUR"; lineItemContainer.PaymentMethod = "/Shops/DemoShop/PaymentMethods/Invoice"; lineItemContainer.ShippingMethod = "/Shops/DemoShop/ShippingMethods/Express"; lineItemContainer.TaxArea = "/TaxMatrixGermany/EU"; lineItemContainer.TaxModel = "gross"; lineItemContainer.ProductLineItems = new TProductLineItemIn[] { Product_in }; Order_in.LineItemContainer = lineItemContainer; //initialize order update data Order_up.Path = path; Order_up.BillingAddress = Address_up; Order_up.InProcessOn = new DateTime(2006, 1, 2, 0, 0, 0, DateTimeKind.Local); Order_up.InProcessOnSpecified = true; TAttribute OrderAttr_up = new TAttribute(); OrderAttr_up.Name = "Comment"; OrderAttr_up.Value = "my updated order comment"; Order_up.Attributes = new TAttribute[] { OrderAttr_up }; }
public static ExactBinding <TMessage> TryBuild( AsyncCollectorBindingProvider <TAttribute, TType> parent, Mode mode, BindingProviderContext context) { var patternMatcher = parent._patternMatcher; var parameter = context.Parameter; TAttribute attributeSource = parameter.GetCustomAttribute <TAttribute>(inherit: false); Func <TAttribute, Task <TAttribute> > hookWrapper = null; if (parent.PostResolveHook != null) { hookWrapper = (attrResolved) => parent.PostResolveHook(attrResolved, parameter, parent._nameResolver); } Func <object, object> buildFromAttribute; FuncConverter <TMessage, TAttribute, TType> converter = null; // Prefer the shortest route to creating the user type. // If TType matches the user type directly, then we should be able to directly invoke the builder in a single step. // TAttribute --> TUserType var checker = ConverterManager.GetTypeValidator <TType>(); if (checker.IsMatch(typeof(TMessage))) { buildFromAttribute = patternMatcher.TryGetConverterFunc( typeof(TAttribute), typeof(IAsyncCollector <TMessage>)); } else { var converterManager = parent._converterManager; // Try with a converter // Find a builder for : TAttribute --> TType // and then couple with a converter: TType --> TParameterType converter = converterManager.GetConverter <TMessage, TType, TAttribute>(); if (converter == null) { // Preserves legacy behavior. This means we can only have 1 async collector. // However, the collector's builder object can switch. throw NewMissingConversionError(typeof(TMessage)); } buildFromAttribute = patternMatcher.TryGetConverterFunc( typeof(TAttribute), typeof(IAsyncCollector <TType>)); } if (buildFromAttribute == null) { return(null); } ParameterDescriptor param; if (parent.BuildParameterDescriptor != null) { param = parent.BuildParameterDescriptor(attributeSource, parameter, parent._nameResolver); } else { param = new ParameterDescriptor { Name = parameter.Name, DisplayHints = new ParameterDisplayHints { Description = "output" } }; } var cloner = new AttributeCloner <TAttribute>(attributeSource, context.BindingDataContract, parent._nameResolver, hookWrapper); return(new ExactBinding <TMessage>(cloner, param, mode, buildFromAttribute, converter)); }
public static ExactBinding <TUserType> TryBuild( BindToInputBindingProvider <TAttribute, TType> parent, BindingProviderContext context) { var cm = parent._converterManager; var patternMatcher = parent._patternMatcher; var parameter = context.Parameter; TAttribute attributeSource = parameter.GetCustomAttribute <TAttribute>(inherit: false); Func <TAttribute, Task <TAttribute> > hookWrapper = null; if (parent.PostResolveHook != null) { hookWrapper = (attrResolved) => parent.PostResolveHook(attrResolved, parameter, parent._nameResolver); } var cloner = new AttributeCloner <TAttribute>(attributeSource, context.BindingDataContract, parent._nameResolver, hookWrapper); Func <object, object> buildFromAttribute; FuncConverter <TType, TAttribute, TUserType> converter = null; // Prefer the shortest route to creating the user type. // If TType matches the user type directly, then we should be able to directly invoke the builder in a single step. // TAttribute --> TUserType var checker = ConverterManager.GetTypeValidator <TType>(); if (checker.IsMatch(typeof(TUserType))) { buildFromAttribute = patternMatcher.TryGetConverterFunc(typeof(TAttribute), typeof(TUserType)); } else { // Try with a converter // Find a builder for : TAttribute --> TType // and then couple with a converter: TType --> TParameterType converter = cm.GetConverter <TType, TUserType, TAttribute>(); if (converter == null) { return(null); } buildFromAttribute = patternMatcher.TryGetConverterFunc(typeof(TAttribute), typeof(TType)); } if (buildFromAttribute == null) { return(null); } ParameterDescriptor param; if (parent.BuildParameterDescriptor != null) { param = parent.BuildParameterDescriptor(attributeSource, parameter, parent._nameResolver); } else { param = new ParameterDescriptor { Name = parameter.Name, DisplayHints = new ParameterDisplayHints { Description = "input" } }; } return(new ExactBinding <TUserType>(cloner, param, buildFromAttribute, converter)); }
public MessageHandler(TContainer container, TAttribute handlerAttribute, Action <object, TClient, Message> action) { Container = container; Attribute = handlerAttribute; Action = action; }
public void Init() { Console.WriteLine("Catalog3Test: Init"); catalogService = new CatalogService(); catalogService.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); catalogService.PreAuthenticate = true; catalogService.Url = WEBSERVICE_URL; // init paths sort3 = path + "/Tents"; sort2 = sort3 + "/FamilyTents"; sort1 = sort3 + "/IndividualTents"; full = path + "/" + alias; // init test Catalogs that can be used with the create methods Catalog_in.Alias = alias; TLocalizedValue Catalog_in_Name_de = new TLocalizedValue(); Catalog_in_Name_de.LanguageCode = "de"; Catalog_in_Name_de.Value = "Test-Katalog"; TLocalizedValue Catalog_in_Name_en = new TLocalizedValue(); Catalog_in_Name_en.LanguageCode = "en"; Catalog_in_Name_en.Value = "test Catalog"; Catalog_in.Name = (new TLocalizedValue[] { Catalog_in_Name_de, Catalog_in_Name_en }); Catalog_in.IsVisible = true; Catalog_in.IsVisibleSpecified = true; Catalog_in.ParentCatalog = path; TAttribute attr = new TAttribute(); attr.Name = "Date"; attr.Type = "DateTime"; attr.Value = "2005-12-24T10:00:00"; Catalog_in.Attributes = new TAttribute[] { attr }; TAttribute layout1 = new TAttribute(); layout1.Name = "Content-Order"; layout1.Value = "Base_Products_Pages"; TAttribute layout2 = new TAttribute(); layout2.Name = "Content-Pages"; layout2.Value = "Pages_SingleColumn"; Catalog_in.TemplateTypes = new TAttribute[] { layout1, layout2 }; // init test Catalogs that can be used with the create methods Catalog_up.Path = full; TLocalizedValue Catalog_up_Name_de = new TLocalizedValue(); Catalog_up_Name_de.LanguageCode = "de"; Catalog_up_Name_de.Value = "anderer Test-Katalog"; TLocalizedValue Catalog_up_Name_en = new TLocalizedValue(); Catalog_up_Name_en.LanguageCode = "en"; Catalog_up_Name_en.Value = "updated test Catalog"; Catalog_up.Name = (new TLocalizedValue[] { Catalog_up_Name_de, Catalog_up_Name_en }); Catalog_up.IsVisible = false; Catalog_up.IsVisibleSpecified = true; TAttribute attr_up = new TAttribute(); attr_up.Name = "Date"; attr_up.Type = "DateTime"; attr_up.Value = "2005-12-24T18:00:00"; Catalog_up.Attributes = new TAttribute[] { attr_up }; TAttribute layout3 = new TAttribute(); layout3.Name = "Content-Order"; layout3.Value = "Pages_Products_Base"; TAttribute layout4 = new TAttribute(); layout4.Name = "Content-Pages"; layout4.Value = "Pages_TwoColumns"; Catalog_in.TemplateTypes = new TAttribute[] { layout3, layout4 }; // init parameters for sort methods Catalog_sort1.Path = sort1; Catalog_sort2.Path = sort2; Catalog_sort2.sort = "byPriceDESC"; Catalog_sort3.Path = sort3; Catalog_sort3.sort = "byPriceASC"; Catalog_sort3.allSub = true; // delete test catalog if exists TExists_Return[] Catalogs_out = catalogService.exists(new string[] { full }); if (Catalogs_out[0].exists) { catalogService.delete(new string[] { full }); } }
public void Init() { serviceClient = new OrderServiceClient(); // create test Orders that can be used with the create and update methods Order_in.Alias = alias; Order_in.Customer = "/Shops/DemoShop/Customers/1001"; Order_in.CreationDate = new DateTime(2006, 1, 1, 12, 0, 0, DateTimeKind.Local); Order_in.ViewedOn = new DateTime(2006, 1, 1, 23, 59, 0, DateTimeKind.Local); Order_in.ViewedOnSpecified = true; TProductLineItemIn productLineItem = new TProductLineItemIn(); productLineItem.Product = "/Shops/DemoShop/Products/ho_1112105010"; productLineItem.Quantity = 10; productLineItem.QuantitySpecified = true; TLineItemContainerIn lineItemContainer = new TLineItemContainerIn(); lineItemContainer.CurrencyID = "EUR"; lineItemContainer.PaymentMethod = "/Shops/DemoShop/PaymentMethods/Invoice"; lineItemContainer.ShippingMethod = "/Shops/DemoShop/ShippingMethods/Express"; lineItemContainer.TaxArea = "/TaxMatrixGermany/EU"; lineItemContainer.TaxModel = "gross"; lineItemContainer.ProductLineItems = new TProductLineItemIn[] { productLineItem }; Order_in.LineItemContainer = lineItemContainer; TAddress bill = new TAddress(); bill.FirstName = "Klaus"; bill.LastName = "Klaussen"; bill.Street = "Musterstraße 2"; bill.EMail = "*****@*****.**"; bill.Birthday = new DateTime(1976, 9, 25, 11, 33, 0, DateTimeKind.Local); bill.BirthdaySpecified = true; bill.VerifiedOn = new DateTime(2005, 1, 1, 0, 0, 0, DateTimeKind.Local); bill.VerifiedOnSpecified = true; Order_in.BillingAddress = bill; TAttribute attr = new TAttribute(); attr.Name = "Comment"; attr.Value = "my Order comment"; Order_in.Attributes = new TAttribute[] { attr }; Order_update.Path = path + alias; Order_update.CreationDate = new DateTime(2006, 1, 1, 2, 2, 2, DateTimeKind.Local); Order_update.CreationDateSpecified = true; Order_update.ViewedOn = new DateTime(2006, 1, 2, 0, 0, 0, DateTimeKind.Local); Order_update.ViewedOnSpecified = true; TAddress bill_update = new TAddress(); bill_update.FirstName = "Hans"; bill_update.LastName = "Hanssen"; bill_update.Street = "Musterstraße 2b"; bill_update.Birthday = new DateTime(1976, 9, 25, 11, 33, 0, DateTimeKind.Local); bill_update.BirthdaySpecified = true; bill_update.VerifiedOn = new DateTime(2005, 1, 1, 0, 0, 0, DateTimeKind.Local); bill_update.VerifiedOnSpecified = true; Order_update.BillingAddress = bill_update; TAttribute attr_update = new TAttribute(); attr_update.Name = "Comment"; attr_update.Value = "my updated Order comment"; Order_update.Attributes = new TAttribute[] { attr_update }; }
public void Init() { serviceClient = new ProductServiceClient(); // create test Products that can be used with the create and update methods Product_in.Alias = alias; TLocalizedValue name_de = new TLocalizedValue(); name_de.LanguageCode = "de"; name_de.Value = "Test-Hauptprodukt"; TLocalizedValue name_en = new TLocalizedValue(); name_en.LanguageCode = "en"; name_en.Value = "test master product"; Product_in.Name = new TLocalizedValue[] { name_de, name_en }; Product_in.Class = "/Shops/DemoShop/ProductTypes/Shoe"; Product_in.TaxClass = "/TaxMatrixGermany/normal"; Product_in.IsVisible = true; Product_in.IsVisibleSpecified = true; Product_in.IsNew = true; Product_in.IsNewSpecified = true; Product_in.PriceQuantity = (float)1; Product_in.PriceQuantitySpecified = true; Product_in.MinOrder = (float)1; Product_in.MinOrderSpecified = true; Product_in.IntervalOrder = (float)1; Product_in.IntervalOrderSpecified = true; Product_in.OrderUnit = "/Units/piece"; Product_in.Weight = (float)240; Product_in.WeightSpecified = true; Product_in.WeightUnit = "/Units/gram"; Product_in.RefAmount = (float)1; Product_in.RefAmountSpecified = true; Product_in.RefContentAmount = (float)0.240; Product_in.RefContentAmountSpecified = true; Product_in.RefUnit = "Units/gram/kilogram"; Product_in.StockLevel = (float)140; Product_in.StockLevelSpecified = true; Product_in.StockLevelAlert = (float)100; Product_in.StockLevelAlertSpecified = true; TProductPrice price = new TProductPrice(); price.Price = (float)123; price.CurrencyID = "EUR"; price.TaxModel = "gross"; Product_in.ProductPrices = new TProductPrice[] { price }; TAttribute attr = new TAttribute(); attr.Name = "AvailabilityDate"; attr.Type = "DateTime"; attr.Value = "2005-12-24T10:00:00"; Product_in.Attributes = new TAttribute[] { attr }; Product_update.Path = path + alias; TLocalizedValue name_de_update = new TLocalizedValue(); name_de_update.LanguageCode = "de"; name_de_update.Value = "verändertes Test-Hauptprodukt"; TLocalizedValue name_en_update = new TLocalizedValue(); name_en_update.LanguageCode = "en"; name_en_update.Value = "updated test master product"; Product_update.Name = new TLocalizedValue[] { name_de_update, name_en_update }; Product_update.IsVisible = true; Product_update.IsVisibleSpecified = true; Product_update.IsNew = true; Product_update.IsNewSpecified = true; Product_update.PriceQuantity = (float)1; Product_update.PriceQuantitySpecified = true; Product_update.MinOrder = (float)1; Product_update.MinOrderSpecified = true; Product_update.IntervalOrder = (float)1; Product_update.IntervalOrderSpecified = true; Product_update.Weight = (float)240; Product_update.WeightSpecified = true; Product_update.RefAmount = (float)1; Product_update.RefAmountSpecified = true; Product_update.RefContentAmount = (float)0.240; Product_update.RefContentAmountSpecified = true; Product_update.StockLevel = (float)140; Product_update.StockLevelSpecified = true; Product_update.StockLevelAlert = (float)100; Product_update.StockLevelAlertSpecified = true; TProductPrice price_update = new TProductPrice(); price_update.Price = (float)123.50; price_update.CurrencyID = "EUR"; price_update.TaxModel = "gross"; Product_update.ProductPrices = new TProductPrice[] { price_update }; TAttribute attr_update = new TAttribute(); attr_update.Name = "AvailabilityDate"; attr_update.Type = "DateTime"; attr_update.Value = "2005-12-24T18:00:00"; Product_update.Attributes = new TAttribute[] { attr_update }; }
public void Init() { // try to get customer groups at first, because they are different since patch 7 string customerGroupsPath = "/Shops/DemoShop/Groups/"; string[] customerGroups = new string[] { customerGroupsPath + "NewCustomer", customerGroupsPath + "RegularCustomer" }; WebServiceConfiguration WSConfig = new WebServiceConfiguration(); CustomerGroupService custService = new CustomerGroupService(); custService.Credentials = new System.Net.NetworkCredential(WebServiceConfiguration.WEBSERVICE_LOGIN, WebServiceConfiguration.WEBSERVICE_PASSWORD); custService.PreAuthenticate = true; custService.Url = WSConfig.WEBSERVICE_URL; TGetList_Return[] retGroups = custService.getList(); customerGroups[0] = customerGroupsPath + retGroups[0].Alias; customerGroups[1] = customerGroupsPath + retGroups[1].Alias; serviceClient = new PriceListServiceClient(); // create test PriceLists that can be used with the create and update methods PriceList_in.Alias = alias; PriceList_in.CurrencyID = "EUR"; PriceList_in.CustomerGroups = new string[] { customerGroups[0] }; PriceList_in.Customers = new string[] { "/Shops/DemoShop/Customers/1001" }; TLocalizedValue name_de = new TLocalizedValue(); name_de.LanguageCode = "de"; name_de.Value = "Meine Preisliste"; TLocalizedValue name_en = new TLocalizedValue(); name_en.LanguageCode = "en"; name_en.Value = "my price list"; PriceList_in.Name = new TLocalizedValue[] { name_de, name_en }; PriceList_in.TaxModel = "gross"; PriceList_in.ValidFrom = new DateTime(2005, 12, 1, 0, 0, 0, DateTimeKind.Local); PriceList_in.ValidTo = new DateTime(2005, 12, 31, 0, 0, 0, DateTimeKind.Local); TAttribute attr = new TAttribute(); attr.Name = "CreationDate"; attr.Type = "DateTime"; attr.Value = "2006-01-01T00:00:00"; PriceList_in.Attributes = new TAttribute[] { attr }; PriceList_update.Path = path + alias; TLocalizedValue name_de_update = new TLocalizedValue(); name_de_update.LanguageCode = "de"; name_de_update.Value = "Meine geänderte Preisliste"; TLocalizedValue name_en_update = new TLocalizedValue(); name_en_update.LanguageCode = "en"; name_en_update.Value = "my updated price list"; PriceList_update.Name = new TLocalizedValue[] { name_de_update, name_en_update }; // IMPORTANT!!! // .NET has the terrible behavior, to set all boolean and numeric value (incl. dates) that are not // defined to "false" resp. "0" // So if you update an object and do not set the "IsVisible" flag, it will set the object to // invisible!!! PriceList_update.ValidFrom = new DateTime(2005, 12, 1, 0, 0, 0, DateTimeKind.Local); PriceList_update.ValidTo = new DateTime(2005, 12, 31, 0, 0, 0, DateTimeKind.Local); TAttribute attr_update = new TAttribute(); attr_update.Name = "CreationDate"; attr_update.Type = "DateTime"; attr_update.Value = "2006-01-01T11:11:11"; PriceList_update.Attributes = new TAttribute[] { attr_update }; }
/// <summary> /// Get attribute from the method, and if not there, tries to get it from the class. /// Uses default inheritance rule: "no" for method, "yes" for class. /// </summary> /// <typeparam name="TAttribute"></typeparam> /// <returns></returns> public TAttribute GetMethodOrClassAttribute <TAttribute>() where TAttribute : Attribute { TAttribute attrib = this.GetMethodAttribute <TAttribute>() ?? this.GetClassAttribute <TAttribute>(); return(attrib); }
public void Init() { // initialize orderService orderService = new OrderService(); orderService.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); orderService.PreAuthenticate = true; orderService.Url = WEBSERVICE_URL; // initialize addresses TAddressNamed Address_in = new TAddressNamed(); Address_in.EMail = "*****@*****.**"; Address_in.FirstName = "Klaus"; Address_in.LastName = "Klaussen"; Address_in.Street = "Musterstraße 2"; Address_in.Street2 = "Ortsteil Niederfingeln"; TAttribute jobTitle= new TAttribute(); jobTitle.Name="JobTitle"; jobTitle.Value="best Job"; TAttribute salutation = new TAttribute(); salutation.Name="Salutation"; salutation.Value="Dr."; Address_in.Attributes = new TAttribute[]{jobTitle,salutation}; TAddressNamed Address_up = new TAddressNamed(); Address_up.FirstName = "Hans"; Address_up.LastName = "Hanssen"; Address_up.Street = "Musterstraße 2b"; Address_up.Street2 = "Ortsteil Oberfingeln"; //initialize order input data Order_in.Alias = alias; Order_in.Customer = customer; Order_in.BillingAddress = Address_in; Order_in.CreationDate = new DateTime(2006, 1, 1, 12, 0, 0, DateTimeKind.Local); Order_in.ViewedOn = new DateTime(2006, 1, 1, 23, 59, 0, DateTimeKind.Local); Order_in.ViewedOnSpecified = true; TAttribute OrderAttr_in = new TAttribute(); OrderAttr_in.Name = "Comment"; OrderAttr_in.Value="my order comment"; Order_in.Attributes = new TAttribute[] { OrderAttr_in }; TProductLineItemIn Product_in = new TProductLineItemIn(); Product_in.Product = "/Shops/DemoShop/Products/ho_1112105010"; Product_in.Quantity = 10; TLineItemContainerIn lineItemContainer = new TLineItemContainerIn(); lineItemContainer.CurrencyID = "EUR"; lineItemContainer.PaymentMethod = "/Shops/DemoShop/PaymentMethods/Invoice"; lineItemContainer.ShippingMethod = "/Shops/DemoShop/ShippingMethods/Express"; lineItemContainer.TaxArea = "/TaxMatrixGermany/EU"; lineItemContainer.TaxModel = "gross"; lineItemContainer.ProductLineItems = new TProductLineItemIn[]{Product_in}; Order_in.LineItemContainer = lineItemContainer; //initialize order update data Order_up.Path = path; Order_up.BillingAddress = Address_up; Order_up.InProcessOn = new DateTime(2006, 1, 2, 0, 0, 0, DateTimeKind.Local); Order_up.InProcessOnSpecified = true; TAttribute OrderAttr_up = new TAttribute(); OrderAttr_up.Name = "Comment"; OrderAttr_up.Value = "my updated order comment"; Order_up.Attributes = new TAttribute[] { OrderAttr_up }; }