private static Property GetProperty(SampleClassificationObjectType.SupportedProperties propertyId, SampleResourceEntry resourceEntry) { if (resourceEntry == null) { throw new PropertyRetrievalException(String.Format(CultureInfo.CurrentCulture, "DataSource must not be null. DataSource name: {0}", resourceEntry.GetType().Name)); } try { switch (propertyId) { case SampleClassificationObjectType.SupportedProperties.Comments: return(new StringProperty((byte)propertyId, resourceEntry.Comments)); case SampleClassificationObjectType.SupportedProperties.ResourceId: return(new StringProperty((byte)propertyId, resourceEntry.ResourceId)); case SampleClassificationObjectType.SupportedProperties.SourceString: return(new StringProperty((byte)propertyId, resourceEntry.Value)); default: { string message = String.Format(CultureInfo.CurrentCulture, "Cannot provide property {0} from datasource of type {1}.", propertyId.ToString(), resourceEntry.GetType().Name); throw new InvalidOperationException(message); } } } catch (NullReferenceException e) { return(null); } }
private static Property GetSelfProperty(SampleClassificationObjectType.SupportedProperties propertyId, SampleClassificationObjectType cO) { if (Object.ReferenceEquals(cO, null)) { throw new NullReferenceException(String.Format(CultureInfo.CurrentCulture, "DataSource must not be null. DataSource name: {0}", cO.GetType().Name)); } switch (propertyId) { case SampleClassificationObjectType.SupportedProperties.Comments: return(new StringProperty((byte)propertyId, cO.Comments)); case SampleClassificationObjectType.SupportedProperties.ResourceId: return(new StringProperty((byte)propertyId, cO.ResourceId)); case SampleClassificationObjectType.SupportedProperties.SourceString: return(new StringProperty((byte)propertyId, cO.SourceString)); default: { string message = String.Format(CultureInfo.CurrentCulture, "Cannot provide property {0} from datasource of type {1}.", propertyId.ToString(), cO.GetType().Name); throw new InvalidOperationException(message); } } }