private string WriteDSEntity(IDesignScriptEntity entity, string paramName = null) { Type type = entity.GetType(); Type[] interfaces = type.GetInterfaces(); //Find first available writer for this entity and the serialize. for (int i = interfaces.Length - 1; i >= 0; --i) { Func <GeometryExpressionBuilder, IDesignScriptEntity, string, string> writer; if (mWriters.TryGetValue(interfaces[i], out writer)) { return(writer(this, entity, paramName)); } } throw new NotImplementedException(); }
/// <summary> /// Finds the underlying interface implementation type and uses appropriate /// writer to serialize the given entity. /// </summary> /// <param name="entity"></param> /// <param name="typeName">output type name</param> /// <returns></returns> public IGeometryDataCollection WriteEntity(IDesignScriptEntity entity, out string typeName) { Type type = entity.GetType(); Type[] interfaces = type.GetInterfaces(); //Find first available writer for this entity and the serialize. for (int i = interfaces.Length - 1; i >= 0; --i) { Func <IDesignScriptEntity, IGeometryDataCollection> writer; if (mDataWriters.TryGetValue(interfaces[i], out writer)) { typeName = mDataTypes[interfaces[i]]; return(writer(entity)); } } throw new NotImplementedException(); }