public object NewInstance(IProject proj, bool initialize) { object ob = CreateInstance(proj); string name = WrappedTypeName.ToLower() + (++counter).ToString(); int i = name.LastIndexOf('.'); if (i != -1) { if (i < name.Length) { name = name.Substring(i + 1); } else { name = name.Replace(".", ""); } } ObjectWrapper ow = CreateWrapper(); try { ow.Loading = true; ObjectWrapper.Bind(proj, this, ow, ob, !initialize); // Initialize the properties after creating the wrapper, since some properties // may be implemented in the wrapper foreach (ItemGroup group in groups) { foreach (ItemDescriptor item in group) { PropertyDescriptor prop = item as PropertyDescriptor; if (prop != null && prop.InitWithName) { prop.SetValue(ob, name); } } } } finally { ow.Loading = false; } return(ob); }
public object NewInstance(IProject proj, bool initialize) { object ob = CreateInstance(proj); string name = WrappedTypeName.ToLower() + (++counter).ToString(); int i = name.LastIndexOf('.'); if (i != -1) { if (i < name.Length) { name = name.Substring(i + 1); } else { name = name.Replace(".", ""); } } foreach (ItemGroup group in groups) { foreach (ItemDescriptor item in group) { PropertyDescriptor prop = item as PropertyDescriptor; if (prop != null && prop.InitWithName) { prop.SetValue(ob, name); } } } ObjectWrapper ow = CreateWrapper(); ObjectWrapper.Bind(proj, this, ow, ob, !initialize); return(ob); }